19.7.2 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 the SendTargets discovery method to discover the iSCSI targets at a specified IP address:

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

    An alternate discovery method is Internet Storage Name Service (iSNS).

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

    The following command displays information about the targets that is now stored in the discovery database:

    # iscsiadm -m discoverydb -t st -p 10.150.30.72
    # BEGIN RECORD 6.2.0.873-14
    discovery.startup = manual
    discovery.type = sendtargets
    discovery.sendtargets.address = 10.150.30.72
    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
    # END RECORD
  3. Establish a session and log in to a specific target:

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

    # iscsiadm -m session -P 3
    iSCSI Transport Class version 2.0-870
    version 6.2.0.873-14
    Target: iqn.2003-01.com.mydom.host01.x8664:sn.ef8e14f87344 (non-flash)
    	Current Portal: 10.0.0.2:3260,1
    	Persistent Portal: 10.0.0.2:3260,1
    		**********
    		Interface:
    		**********
    		Iface Name: default
    		Iface Transport: tcp
    		Iface Initiatorname: iqn.1994-05.com.mydom:ed7021225d52
    		Iface IPaddress: 10.0.0.2
    		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 their paths under /dev/disk/by-path:

    # ls -l /dev/disk/by-path/
    lrwxrwxrwx  1 root root  9 May 15 21:05
      ip-10.150.30.72:3260-iscsi-iqn.2013-01.com.mydom.host01.x8664:
      sn.ef8e14f87344-lun-0 -> ../../sdb
    lrwxrwxrwx 1 root root  9 May 15 21:05
      ip-10.150.30.72:3260-iscsi-iqn.2013-01.com.mydom.host01.x8664:
      sn.ef8e14f87344-lun-1 -> ../../sdc

    You can view the initialization messages for the LUNs in the /var/log/messages file, for example:

    # 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 as you would any other physical storage device. For example, you can configure it as an LVM physical volume, file system, swap partition, Automatic Storage Management (ASM) disk, or 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.

    Note

    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.