This topic describes how to connect to and use iSCSI volumes from the Linux operating system.

Prerequisites

You have created an iSCSI volume. For more information, see Create an iSCSI volume.

Procedure

  1. Log on to the Linux operating system on your local host.
  2. Install the iscsi-initiator-utils package.

    You need the iscsi-initiator-utils package to connect to the target iSCSI volume. If you have already installed the iscsi-initiator-utils package, skip this step.

    sudo yum install iscsi-initiator-utils
  3. Run the following command to verify that the iSCSI daemon is running.
    • Run the following command if the Linux operating system that you use is RHEL 5 or RHEL 6.
      sudo /etc/init.d/iscsi status
    • For Linux RHEL 7, run the following command.
      sudo service iscsid status

    If the proceeding commands do not return running to you, run the udo /etc/init.d/iscsi start command to start the iSCSI daemon.

  4. Optional. Configure CHAP authentication.
    Note If you enabled CHAP when you created the iSCSI volume, you need to configure CHAP settings before you can use the iSCSI volume.
    1. Run the following command to open the iscsid.conf configuration file.
      vi /etc/iscsi/iscsid.conf
    2. Find CHAP Settings and delete the hash character (#) before the relevant comments, and set the CHAP username and password.
      • Enter the CHAP username that you set when you created the iSCSI volume.
      • Enter the CHAP password that you set when you created the iSCSI volume.
  5. Run the following command to discover the iSCSI volume.
    iscsiadm -m discovery -t st -p 10.0.0.0:3260
    • 10.0.0.0 is the IP address of the block gateway. You can choose About > Network information to obtain the IP address.
    • 3260 is the connection port. Do not change the port.
  6. Run the following command to mount the iSCSI volume.
    iscsiadm -m node -T iqn.2009-09.com.aliyun.iscsi-sgw:0test-test730 -p 10.0.0.0:3260 -l
    • iqn.2009-09.com.aliyun.iscsi-sgw:0test-test730 is the iSCSI target. You can obtain the target name in step 2.
    • 10.0.0.0 is the IP address of the block gateway. You can choose About > Network information to obtain the IP address.
    • 3260 is the connection port. Do not change the port.
    Note Due to the limits of the iSCSI protocol, do not mount one iSCSI volume to multiple Linux clients.
  7. Run the fdisk -l or lsblk command to view the iSCSI volume.

    In this state, the mounted iSCSI volume becomes an available raw disk. You can read data from and write data to the iSCSI volume from a local computer.

    View iSCSI volume information