Install and Manage iSCSI

Internet SCSI (iSCSI) is a network protocol that allows you to use of the SCSI protocol over TCP/IP networks. It is good alternative to Fibre Channel-based SANs. You can easily manage, mount and format iSCSI Volumes under Linux. It allows access to storage over Ethernet.

Open-iSCSI Project

The Open-iSCSI project is a high-performance, transport independent, multi-platform implementation of iSCSI. Open-iSCSI is partitioned into user and kernel parts. To use iSCSI on CentOS, you just need to install the iscsi-initiator-utils RPM package. This package provides the server daemon for the iSCSI protocol, as well as the utility programs used to manage it. The RPM package can be installed using yum command:

# yum install iscsi-initiator-utils

iSCSI Configuration

There are a few steps that are needed to set up a system to use iSCSI storage:

  1. iSCSI startup using the init script or manual startup.
  2. Discover targets.
  3. Automate target logins for future system reboots.
  4. You also may need to obtain iSCSI username, password
  5. You will need the storage server IP address (target host)

Configure iSCSI

If you need a user name and password to access the storage, open /etc/iscsi/iscsid.conf to configure user name and password:

node.session.auth.username = MY_ISCSI_USER_NAME
node.session.auth.password = MY_ISCSI_PASSWORD
discovery.sendtargets.auth.username = MY_ISCSI_USER_NAME
discovery.sendtargets.auth.password = MY_ISCSI_PASSWORD

You may also need to tweak and set other options. Refer to man page for more information.

Discover Targets

Use the iscsiadm command, which is the command-line tool allowing discovery and login to iSCSI targets, as well as access and management of the open-iscsi database. If your storage server IP address is 192.168.1.5, enter:

# iscsiadm -m discovery -t sendtargets -p 192.168.1.5
# /etc/init.d/iscsi start

Now there should be a block device under /dev directory. To obtain new device name, type:

# fdisk -l

On my system, '/dev/sda' was my new block device.

Format and Mount

If a partition and file system don't already exist on the target, they must be created using fdisk and mkfs.ext3 commands:

# fdisk /dev/sda
  (type n to create a new partition, p for primary, and then 1 for
    the partition number, the defaults for the remaining questions are fine...)
# mkfs.ext3 /dev/sda1

Mount new partition:

# mkdir /mnt/iscsi
# mount /dev/sda1 /mnt/iscsi

Mount iSCSI Automatically At Boot Time

Turn on the iSCSI service at boot time:

# chkconfig iscsi on

Open /etc/fstab file and append this directive:

/dev/sda1 /mnt/iscsi ext3 _netdev 0 0

Save and close the file.

For More Information