CentOS 7.x iSCSI initiator client setup
From Notes_Wiki
Home > CentOS > CentOS 7.x > File sharing > iSCSI > CentOS 7.x iSCSI initiator client setup
To use iSCSI drive from a target on a client machine using initiator use following steps:
- Ensure that package iscsi-initiator-utils is present
- Ensure that InitiatorName is present in /etc/iscsi/initiatorname.iscsi file
- Ensure that iscsid service is enabled and running
- 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
- OR
- 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
- Other option is to run discovery with "-l" so that automatic login to all discovered luns is done.
- Check status of current iscsi sessions on server using (Only in case of Linux target iscsi server):
- targetcli sessions
- On client check sessions using:
- iscsiadm -m session
- 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:
- 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.
- On client disconnect session using:
- iscsiadm -m session -r <session_number> -u
-
- where session number is listed using 'iscsiadm -m session' command
- 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
- 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
- On client various information about iSCSI target is cached in sub-folders inside /var/lib/iscsi folder.
Refer:
Home > CentOS > CentOS 7.x > File sharing > iSCSI > CentOS 7.x iSCSI initiator client setup