Accessing Block Storage on Linux

Connecting to MPIO iSCSI LUNs on Linux

Before starting, make sure the host accessing the Block Storage volume has been authorized through the SoftLayer Portal:

  1. From the Block Storage listing page, click the Actions button associated with the newly provisioned volume, and click Authorize Host.
  2. Select the desired host(s) from the list and click Submit; this authorizes the host(s) to access the volume.

Mounting Block Storage volumes

Following are the steps required to connect a Linux-based SoftLayer compute instance to a multipath input/output (MPIO) Internet Small Computer System Interface (iSCSI) logical unit number (LUN). The example is based on Red Hat Enterprise Linux 6. The steps can be adjusted for other Linux distributions according to the operating system (OS) vendor documentation.

Note: The Host IQN, username, password, and target address referenced in the instructions can be obtained from the Block Storage Details screen in the SoftLayer Portal.

  1. Install the iSCSI and multipath utilities to your host
    1. # yum install iscsi-initiator-utils device-mapper-multipath (RHEL/CentOS)
    2. # apt-get install open-iscsi multipath-tools (Ubuntu/Debian)
  2. Create or edit your multipath configuration file.
    1. Edit /etc/multipath.conf with the minimum configuration provided in the following commands.

      Be aware that for RHEL7/CentOS7, multipath.conf can be blank as the OS has built-in configurations.

      defaults {
      user_friendly_names no
      max_fds max
      flush_on_last_del yes
      ​queue_without_daemon no
      dev_loss_tmo infinity
      fast_io_fail_tmo 5
      }
      # All data under blacklist must be specific to your system.
      blacklist {
      wwid "SAdaptec*"
      devnode "^hd[a-z]"
      devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
      devnode "^cciss.*"
      }
      devices {
      device {
      vendor "NETAPP"
      product "LUN"
      path_grouping_policy group_by_prio
      features "3 queue_if_no_path pg_init_retries 50"
      prio "alua"
      path_checker tur
      failback immediate
      path_selector "round-robin 0"
      hardware_handler "1 alua"
      rr_weight uniform
      rr_min_io 128
      getuid_callout "/lib/udev/scsi_id -g -u -d /dev/%n"
      }
      }

  3. Load the multipath module, start multipath services and set it start on boot.
    1. # modprobe dm-multipath
    2. # service multipathd start
    3. # chkconfig multipathd on
  4. Verify multipath is working.
    1. # multipath -l (if it returns blank at this time it is working. RHEL 7/CentOS 7 may return No fc_host device for 'host-1', which can be ignored. )
  5. Update /etc/iscsi/initiatorname.iscsi file with the IQN from the SoftLayer Portal. Enter the value as lower case. 
    InitiatorName="value-from-the-SL-Portal"
  6. Edit the CHAP settings in /etc/iscsi/iscsid.conf using the username and password from the SoftLayer Portal (minus the quotation marks). Use upper case for CHAP names.
        node.session.auth.authmethod = CHAP
        node.session.auth.username = "Username-value-from-SL-Portal"
        node.session.auth.password = "Password-value-from-SL-Portal"
        discovery.sendtargets.auth.authmethod = CHAP
        discovery.sendtargets.auth.username = "Username-value-from-SL-Portal"
        discovery.sendtargets.auth.password = "Password-value-from-SL-Portal" 

    Note:Leave the other CHAP settings commented. SoftLayer storage uses only one-way authentication.
              
  7. Set iSCSI to start at boot and start it at this time.
    1. # chkconfig iscsi on
    2. # chkconfig iscsid on
    3. # service iscsi start
    4. # service iscsid start
  8. Discover the device using the Target IP address obtained from the SoftLayer Portal.
    1. Run the discovery against the iSCSI array:
                   # iscsiadm -m discovery -t sendtargets -p "ip-value-from-SL-Portal"
    2. Set the host to automatically log into the iSCSI array:
                   # iscsiadm -m node -L automatic
  9. Verify that the host has logged into the iSCSI array and maintained its sessions.
    1. # iscsiadm -m session
    2. # multipath -l (should report the paths at this time)
  10. Verify the device is connected.  By default the device will attach to /dev/mapper/mpathX where X is the generated ID of the connected device.
    1. # fdisk -l | grep /dev/mapper
      Should report something similar to the following,
            Disk /dev/mapper/3600a0980383030523424457a4a695266: 73.0 GB, 73023881216 byte
      The volume is now mounted and accessible on the host.

Create a file system (optional) 

Following are the steps to create a file system on top of the newly mounted volume. A file system is necessary for most applications to utilize the volume.

  1. Get the disk name.
    1. # fdisk -l | grep /dev/mapper (the disk name returned will be similar to /dev/mapper/XXX).
  2. Create a partition on the disk using fdisk.
    1. # fdisk /dev/mapper/XXX (where XXX represents the disk name returned in Step 1).
    2. Follow the commands codes listed in the Fdisk command table at the bottom of this page.
  3. Create a file system on the new partition.
    1. # fdisk –l /dev/mapper/XXX
    2. The new partition should be listed with the disk, similar to XXXlp1, followed by the size, Type (83), and Linux. Remember the partition name; you’ll need it in Step 3.
    3. # mkfs.ext3 /dev/mapper/XXXlp1 (where XXXlp1represents the partition name is that was returned in Step 2).
  4. Create a mount point for the file system and mount it.
    1. # mkdir /PerfDisk (or where you want to mount the file system).
    2. # mount /dev/mapper/XXXlp1 /PerfDisk (using the partition name from Step 2).
    3. # df -h (you should see your new file system listed).

Fdisk command table

Command

Result

  • *Command: n

Creates a new partition.

  • Command action: p

Makes the partition the primary one.

  • Partition number (1-4): 1

Becomes partition 1 on the disk.

  • First cylinder (1-8877): 1 (default)

Start at cylinder 1.

  • Last cylinder, +cylinders or +size {K, M, G}: 8877 (default)

Hit Enter to go to the last cylinder.

 

  • *Command: t

Sets up the type of partition.

  • Select partition 1.

Selects partition 1 to be set up as a specific type.

  • **Hex code: 83

Selects Linux as the Type (83 is the hex code for Linux).

 

  • *Command: w

Writes the new partition information to the disk.

*Type m for Help.

**Type L to list the hex codes