Skip to main content
Pure1 Support Portal

Configuring iSCSI on Linux for the Pure FlashArray

This document goes over the configuration and best practices to configure iSCSI in Linux.  For our testing we have used RHEL 6.x.  The steps below use commands with example IP addresses and IQNs.  When running the commands, replace the IPs and the IQNs with your own.

Pre-requisites

  1. Make sure that you are using our Linux Best Practices before proceeding. 
  2. If your iSCSI interfaces are on the same subnet, please reference the workaround at the bottom of this document for additional steps. 
  3. The LUN should be attached to the host, via your iSCSI switch before starting this procedure.
  4. You will need to install and configure the following to use iSCSI with RHEL:  

    Install iscsi-initiator-utils

    # yum install iscsi-initiator-utils -y
    
    # yum install lsscsi

    Install multipath

    # yum install device-mapper-multipath

    Enable iscsi at bootup

    # chkconfig iscsid on
    # service iscsid start
    # chkconfig iscsi on
    # service iscsi start

Configuration

Connect to the LUN and Prepare the Pure FlashArray with the Host, LUN, and Host IQN

From RHEL6

Get IQN of the host initiator:

# cat /etc/iscsi/initiatorname.iscsi

 An example of IQN returned: 

InitiatorName=iqn.1994-05.com.redhat:bffc5f96a7fb 

From Pure

Create your Host entry, create your LUN(s), and then enter the IQN for the RHEL6 host into Pure for the host entry you just created.

From RHEL6

You can now discover the IQN of the Pure FlashArray (Any IP address that the array uses for iSCSI traffic should work:

# iscsiadm -m discovery -t st -p 10.124.3.158
10.124.3.159:3260,1 iqn.2010-06.com.purestorage:flasharray.38e69528198<wbr/>fee76
10.124.3.158:3260,1 iqn.2010-06.com.purestorage:flasharray.38e69528198<wbr/>fee76

From Pure

Confirm the above IQNs are the correct IQNs (you want to make sure you are connecting to the correct array):

# pureport list

From RHEL6

Log the iSCSI sessions into Pure by running the following command (one session or more sessions if wanting to use multipath):

# iscsiadm -m node -T iqn.2010-06.com.purestorage:flasharray.38e69528198<wbr/>fee76 -p 10.124.3.159 -l
# iscsiadm -m node -T iqn.2010-06.com.purestorage:flasharray.38e69528198<wbr/>fee76 -p 10.124.3.158 -l

Open iscsi initiator (i.e iscsiadm) utility provides a feature to create multiple interfaces.

iscsiadm -m iface -I <iface name> -o new

"You may then take the "-l" off the above command to display info about the iSCSI target:"

# iscsiadm -m node -T iqn.2010-06.com.purestorage:flasharray.38e69528198<wbr/>fee76 -p 10.124.3.159
# iscsiadm -m node -T iqn.2010-06.com.purestorage:flasharray.38e69528198<wbr/>fee76 -p 10.124.3.158

Now update the newly created interface with a uniq initiator name

iscsiadm -m iface -I <iface name> -o update -n iface.initiatorname -v <initiator name>

log in to the target ip with this newly created interface

iscsiadm -m node --targetname iqn.2010-06.com.purestorage:flasharray.38e69528198 -I <iface name> -p 10.124.3.159 --login

To add automatic login at boot, run:

# iscsiadm -m node -T iqn.2010-06.com.purestorage:flasharray.38e69528198<wbr/>fee76 -p 10.124.3.159 --op update -n node.startup -v automatic
# iscsiadm -m node -T iqn.2010-06.com.purestorage:flasharray.38e69528198<wbr/>fee76 -p 10.124.3.158 --op update -n node.startup -v automatic

or:

# iscsiadm -m node -L automatic

Confirm the Pure LUNs are listed on RHEL6:

# lsscsi

Create a Partition

From RHEL6

  1. List the actual LUNs and note the path for your new Pure LUN:
    # fdisk -l 
  2. Enter fdisk for the new LUN using the path. (steps for LVM (pvcreate, vgcreate, lvcreate) will be added here later):
    # fdisk /dev/sdb
  3.  See info about the LUN:
    # p
  4. Create New Partition:
    # n
  5. Select either Extended or Primary (choosing Extended in this example)
    # e
  6. Choose size or use default number "1" to use entire LUN:
    # 1
  7. Create New "logical" partition inside the above partition which is basically a container:
    # n 
  8. Choose the letter "l" for logical:
    # l
  9. Choose size or use the default number "1" to use entire LUN:
    # 1
  10. Check for new partition and logical partition and note down the Device path (this example uses /dev/sdb5):
    # p
  11. Write to the partition table to sync it and confirm connectivity:
    # w
    # ctrl-c to exit fdisk

Format LUN to ext4 Filesystem

You have a few options:

No automatic unmap:

# mkfs.ext4 /dev/sdb5

Or, to enable automatic unmap for our thin-provisioning array, use the '-o discard' option when formatting:

# mkfs.ext4 -o discard /dev/sdb5

 (This will cause the RHEL 6.x to issue the UNMAP command, which in turn causes space to be released back to the array for any deletions in that ext4 file system.  This will only work on Physical RDM datastores, discard will not work on a disk mapped virtually via ESX.)

Create the Mount Point for the Partition and Mount the Partition

  1. Create a directory where you'll mount the Pure LUN partition:
    # mkdir /mnt/iscsi
  2. Find and copy the UUID of the partition so you may use the UUID to mount an iscsi LUN partition:
    # blkid
  3. Backup the fstab file. 
    # cp /etc/fstab /etc/fstabBAK
  4. Add the UUID to the fstab file (in this example the UUID is 3c2aecaf-2dc0-47e1-aa39-e43e6f96d84c):
    # vim /etc/fstab

    EXAMPLE OF EDITED FSTAB FILE (our LUN partition is the last row):

    /dev/mapper/vg_quahogrhe6-lv_root /                       ext4    defaults        1 1
    
    UUID=447642c9-d5cd-4a1c-8479-e38ee1147b70 /boot                   ext4    defaults        1 2
    
    /dev/mapper/vg_quahogrhe6-lv_swap swap                    swap    defaults        0 0
    
    tmpfs                   /dev/shm                tmpfs   defaults        0 0
    
    devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
    
    sysfs                   /sys                    sysfs   defaults        0 0
    
    proc                    /proc                   proc    defaults        0 0
    
    UUID="3c2aecaf-2dc0-47e1-aa39-e43e6f96d84c"     /mnt/iscsi   ext4    _netdev 0 0

    Note:  we are using '_netdev' so the system does not try and mount the partition until after networking is up.

  5. Save and exit the file.
  6. Mount the partition:
    # mount /mnt/iscsi

     or

    # mount -a

     or if you require to mount the partition as read-only:

    # mount -o rw /mnt/iscsi
  7.  Verify the partition is mounted (this will also list the options for the mounted partition.  i.e.  "/dev/sdb5 on /data type ext4 (rw,_netdev)"):

    # mount
  8.  Confirm that the /mnt/iscsi folder is connected to the partition:

    # df -h /mnt/iscsi

Workaround if your iSCSI Interfaces Are on the Same Subnet


Source: Red Hat KB https://access.redhat.com/solutions/24141

Issue

  • Linux sends tcp reset (RST) packets to open iscsi connections
  • Connections to iscsi devices fail
  • Discovering or logging into a target via one of the interfaces on the same subnet as others results in failures:
    # iscsiadm -m discovery -t st -p 192.168.2.2 -I ieth0
    iscsiadm: connect to 192.168.2.2 timed out
    iscsiadm: connect to 192.168.2.2 timed out
    iscsiadm: connect to 192.168.2.2 timed out
    iscsiadm: connect to 192.168.2.2 timed out
    iscsiadm: connect to 192.168.2.2 timed out
    iscsiadm: connect to 192.168.2.2 timed out
    iscsiadm: connection login retries (reopen_max) 5 exceeded
    iscsiadm: Could not perform SendTargets discovery: encountered connection failure

Environment

  • Red Hat Enterprise Linux (RHEL) 5, 6, 7
  • iscsi-initiator-utils
  • Multiple network adapters on same subnet
  • iscsid configured to bind connections to specific network adapters

Resolution for RedHat 5

  • Set sysctl's ipv4.conf.all.arp_ignoreto 1 to force each interface to only answer ARP requests for its own addresses. Or set net.ipv4.conf.<INTERFACE>.arp_ignore to 1 for each interface that is a path to the iscsi storage.
  • For example, in /etc/sysctl.conf:
    net.ipv4.conf.all.arp_ignore=1
  • Or, to only set it for the relevant interfaces (assuming they are eth0and eth1):
    net.ipv4.conf.eth0.arp_ignore = 1
    net.ipv4.conf.eth1.arp_ignore = 1

Resolution for RedHat 6,7 ( https://access.redhat.com/solutions/53031 )

  • Set sysctl's net.ipv4.conf.default.rp_filter to 2 to force each interface to only answer ARP requests for its own addresses. And set net.ipv4.conf.all.rp_filter to 2 for each interface that is a path to the iscsi storage.
  • For example, in /etc/sysctl.conf
net.ipv4.conf.default.rp_filter = 2
net.ipv4.conf.all.rp_filter = 2

Note: If the system is having RHEL 7 installed, then please enter above sysctl parameters in /etc/sysctl.d/99-sysctl.conf file and then run below command to reread the settings from configuration file:

# sysctl --system