19.7.3 Configuring an iSCSI Initiator

To configure an Oracle Linux system as an iSCSI initiator:

  1. Install the iscsi-initiator-utils package:

    # yum install iscsi-initiator-utils
  2. Use a discovery method to discover the iSCSI targets at the specified IP address.

    You can use either the SendTargets or the Internet Storage Name Service (iSNS) discovery method.

    For example, you would use the SendTargets discovery method as follows:

    # iscsiadm -m discovery -t sendtargets -p,1 iqn.2013-01.com.mydom.host01.x8664:sn.ef8e14f87344

    This command also starts the iscsid service if it is not already running.

    • If the network connection fails, adjust the firewall settings for your network to allow communication with the iSCSI target:

      # iptables -D INPUT -j REJECT --reject-with icmp-host-prohibited
      # iptables -D FORWARD -j REJECT --reject-with icmp-host-prohibited
    • Then, re-run the command using the SendTargets discovery method:

      # iscsiadm -m discovery -t sendtargets -p,1 iqn.2013-01.com.mydom.host01.x8664:sn.ef8e14f87344
  3. Display information about the targets that are now stored in the discovery database by running the following command:

    # iscsiadm -m discoverydb -t st -p
    discovery.startup = manual
    discovery.type = sendtargets
    discovery.sendtargets.address =
    discovery.sendtargets.port = 3260
    discovery.sendtargets.auth.authmethod = None
    discovery.sendtargets.auth.username = <empty>
    discovery.sendtargets.auth.password = <empty>
    discovery.sendtargets.auth.username_in = <empty>
    discovery.sendtargets.auth.password_in = <empty>
    discovery.sendtargets.timeo.login_timeout = 15
    discovery.sendtargets.use_discoveryd = No
    discovery.sendtargets.discoveryd_poll_inval = 30
    discovery.sendtargets.reopen_max = 5
    discovery.sendtargets.timeo.auth_timeout = 45
    discovery.sendtargets.timeo.active_timeout = 30
    discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768
  4. Establish a session and log in to a specific target:

    # iscsiadm -m node -T iqn.2013-01.com.mydom.host01.x8664:sn.ef8e14f87344 \
      -p -l
    Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.localhost.x8664:
    sn.ef8e14f87344, portal:,3260] successful.
  5. Verify that the session is active and display the available LUNs:

    # iscsiadm -m session -P 3
    iSCSI Transport Class version 2.0-870
    Target: iqn.2003-01.com.mydom.host01.x8664:sn.ef8e14f87344 (non-flash)
    	Current Portal:,1
    	Persistent Portal:,1
    		Iface Name: default
    		Iface Transport: tcp
    		Iface Initiatorname: iqn.1994-05.com.mydom:ed7021225d52
    		Iface IPaddress:
    		Iface HWaddress: <empty>
    		Iface Netdev: <empty>
    		SID: 5
    		iSCSI Connection State: LOGGED IN
    		iSCSI Session State: LOGGED_IN
    		Internal iscsid Session State: NO CHANGE
    		Attached SCSI devices:
    		Host Number: 8	State: running
    		scsi8 Channel 00 Id 0 Lun: 0
    			Attached scsi disk sdb		State: running
    		scsi8 Channel 00 Id 0 Lun: 1
    			Attached scsi disk sdc		State: running

    The LUNs are represented as SCSI block devices (sd*) in the local /dev directory, for example:

    # fdisk -l | grep /dev/sd[bc]
    Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
    Disk /dev/sdc: 10.7 GB, 10737418240 bytes, 20971520 sectors

    To distinguish between target LUNs, examine the paths under /dev/disk/by-path:

    # ls -l /dev/disk/by-path/
    lrwxrwxrwx  1 root root  9 May 15 21:05
      sn.ef8e14f87344-lun-0 -> ../../sdb
    lrwxrwxrwx 1 root root  9 May 15 21:05
      sn.ef8e14f87344-lun-1 -> ../../sdc

    You can view the initialization messages for the LUNs in the /var/log/messages file as follows:

    # grep sdb /var/log/messages
    May 18 14:19:36 localhost kernel: [12079.963376] sd 8:0:0:0: [sdb] Attached SCSI disk

    You can configure and use a LUN in the same way that you would any other physical storage device, for example, as an LVM physical volume, a file system, a swap partition, an Automatic Storage Management (ASM) disk, or a raw device.

    Specify the _netdev option when creating mount entries for iSCSI LUNs in /etc/fstab, for example:

    UUID=084591f8-6b8b-c857-f002-ecf8a3b387f3     /iscsi_mount_point     ext4     _netdev   0  0

    This option indicates the file system resides on a device that requires network access, and prevents the system from attempting to mount the file system until the network has been enabled.


    Specify an iSCSI LUN in /etc/fstab by using UUID=UUID rather than the device path. A device path can change after re-connecting the storage or rebooting the system. You can use the blkid command to display the UUID of a block device.

    Any discovered LUNs remain available across reboots provided that the target continues to serve those LUNs and you do not log the system off the target.

For more information, see the iscsiadm(8) and iscsid(8) manual pages.