linux_wiki:iscsi

iSCSI

General Information

iSCSI operations on Linux.

Checklist

  • Distro(s): Enterprise Linux 6/7

Adding Disks

  1. Get the iscsi initiator name on the client
    cat /etc/iscsi/initiatorname.iscsi
  2. Use the initiator name to configure the Host Group, LUN, and Host Affinity on your storage device. (Or send the initiator name to the storage admin)
  3. From the client, discover the available LUNs on the storage device
    iscsiadm --mode discovery -t sendtargets --portal <storage-ip-address>
  4. Start and enable the iscsi daemon
    1. EL6
      service iscsid start
      chkconfig iscsid on
    2. EL7
      systemctl start iscsid
      systemctl enable iscsid
  5. Log-in to the LUN with the iscsi client
    iscsiadm --mode node --targetname <iqn-LUN#-here> --portal <storage-ip-address>:<port> --login
  6. Create /etc/multipath.conf if it doesn't exist
    mpathconf --enable
  7. Configure multipath
    vim /etc/multipath.conf
    # Blacklist exception for your device
    blacklist_exceptions {
        # WWN of LUN via iSCSI LUN group
        wwid "123456789"
    }
     
    # Setup your storage device specifics
    devices {
          device {
                  vendor "DELL"
                  product "MODEL-HERE"
                  # specify other options
          }
     }
     
    # Setup the multipath
    multipaths {
       multipath {
          wwid 123456789
          alias friendly_name_here
       }
    }
  8. Start and enable multipathd
    1. EL6
      service multipathd start
      chkconfig multipathd on
    2. EL7
      systemctl start multipathd
      systemctl enable multipathd
  9. Re-scan the scsi bus
    echo "- - -" > /sys/class/scsi_host/<host_number>/scan
    1. Where <host_number> is something like: host0 (there will probably be host0-3)
    2. The hyphens represent controller,channel,lun, so – - – indicates all controllers, all channels, and all luns should be scanned.
  10. Verify paths
    multipath -ll
  11. Add mount entry to /etc/fstab

Clean Device Removal

Red Hat's recommended procedure for removing storage devices.

  1. Ensure all files open on the device are closed
    lsof | grep <devname>
  2. Backup/move data as needed
  3. Remove device from any software RAID or LVM volume
  4. Remove device from multipath
  5. Flush outstanding I/O (important for raw devices)
    blockdev --flushbufs <device>
  6. Remove references to the device from applications, scripts, etc.
  7. Remove each path to the device from the SCSI subsystem
    echo 1 > /sys/block/<device-name>/device/delete
    1. Where <device-name> can be something like 'sde'

iSCSI Admin

Example iscsiadm commands.

View iscsi target node IP addresses and target names

iscsiadm --mode node

Enable iscsi target: Login to iscsi target

iscsiadm --mode node --targetname <iscsi-target-name> --portal 192.168.1.100:3260 --login

Disable iscsi target: Logout from iscsi target

iscsiadm --mode node --targetname <iscsi-target-name> --portal 192.168.1.100:3260 --logout

Delete iscsi target

iscsiadm --mode node -o delete --targetname <iscsi-target-name> --portal 192.168.1.100:3260

If the iSCSI device that is removed is also multipath'd, remove it from multipath configuration also.

View multipath devices

multipath -ll

Remove (flush) an unused multipath device

multipath -F

After, restart multipathd to ensure it doesn't come back

  • EL6
    service multipathd restart
  • EL7
    systemctl restart multipathd

  • linux_wiki/iscsi.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)