Difference between revisions of "CentOS 7.x iSCSI initiator client setup"

From Notes_Wiki
m
m
Line 32: Line 32:
#:</pre>
#:</pre>
# On client disk should be visible using "fdisk -l".  However if you want to distinguish between various disks (Say if you have 3 disks all three of 5 GB) then you can look at "/dev/disk/by-path/" devices.  In this folder devices are named based on iqn so it is easy to select a disk/lun based on iqn.
# On client disk should be visible using "fdisk -l".  However if you want to distinguish between various disks (Say if you have 3 disks all three of 5 GB) then you can look at "/dev/disk/by-path/" devices.  In this folder devices are named based on iqn so it is easy to select a disk/lun based on iqn.
#If client was already logged in and a new disk is shared it may not become visible directly.  To see new disks either
#*Disconnect session as explained in next step and connect again
#*Or rescan SCSI devices using:
#*:<pre>
#*::echo "- - -" > /sys/class/scsi_host/host&lt;n&gt;/scan
#*:</pre>
#*::where &lt;n&gt; should vary based on folders visible under /sys/class/scsi_host.  We need to scan all hosts once using above command.
# On client disconnect session using:
# On client disconnect session using:
#:<pre>
#:<pre>
Line 50: Line 57:




Refer:
*https://geekpeek.net/rescan-scsi-bus-on-linux-system/


<yambe:breadcrumb>CentOS_7.x_iSCSI|CentOS 7.x iSCSI</yambe:breadcrumb>
<yambe:breadcrumb>CentOS_7.x_iSCSI|CentOS 7.x iSCSI</yambe:breadcrumb>

Revision as of 06:50, 31 October 2017

<yambe:breadcrumb>CentOS_7.x_iSCSI|CentOS 7.x iSCSI</yambe:breadcrumb>

CentOS 7.x iSCSI initiator client setup

To use iSCSI drive from a target on a client machine using initiator use following steps:

  1. Ensure that package iscsi-initiator-utils is present
  2. Ensure that InitiatorName is present in /etc/iscsi/initiatorname.iscsi file
  3. Ensure that iscsid service is enabled and running
  4. Discover the target using below command
    iscsiadm -m discovery -t st -p 192.168.1.200
    OR
    iscsiadm --mode discovery --type sendtargets --portal 192.168.1.200
  5. Login to the discovered target using values from discovery command:
    iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.iscsi.x8664:sn.4f81e28c9c7d -p 192.168.1.200 -l
    Other option is to run discovery with "-l" so that automatic login to all discovered luns is done.
    iscsiadm --mode discovery --type sendtargets --portal 192.168.1.200 -l
  6. Check status of current iscsi sessions on server using (Only in case of Linux target iscsi server):
    targetcli sessions
  7. On client check sessions using:
    iscsiadm -m session
  8. On client disk should be visible using "fdisk -l". However if you want to distinguish between various disks (Say if you have 3 disks all three of 5 GB) then you can look at "/dev/disk/by-path/" devices. In this folder devices are named based on iqn so it is easy to select a disk/lun based on iqn.
  9. If client was already logged in and a new disk is shared it may not become visible directly. To see new disks either
    • Disconnect session as explained in next step and connect again
    • Or rescan SCSI devices using:
      echo "- - -" > /sys/class/scsi_host/host<n>/scan
      where <n> should vary based on folders visible under /sys/class/scsi_host. We need to scan all hosts once using above command.
  10. On client disconnect session using:
    iscsiadm -m session -r <session_number> -u
    where session number is listed using 'iscsiadm -m session' command
  11. On client delete unwanted or wrong discovered sessions using:
    iscsiadm -m discovery
    iscsiadm -m discovery -p 192.168.122.85:3260 -o delete
    If you do not do this and if iscsi server is not available during reboot then system wont boot properly with following lines in /var/log/messages
    Sep 27 20:08:38 barjatiyarklp iscsid: cannot make a connection to 192.168.122.85:3260 (-1,101)
    To fix such a system you would have to boot in single mode and use iscsiadm command with -o delete as explained above
  12. On client various information about iSCSI target is cached in sub-folders inside /var/lib/iscsi folder.


Refer:

<yambe:breadcrumb>CentOS_7.x_iSCSI|CentOS 7.x iSCSI</yambe:breadcrumb>