CentOS – Configuring an iSCSI Volume on CentOS 5.5

CentOS – Configuring an iSCSI Volume on CentOS 5.5

Introduction

iSCSI is a network protocol which allows you to use SCSI over a network and is a cheaper alternative to a Fibre Network or SAN solution.

Connecting iSCSI Volumes to a CentOS server is a simple procedure and is explained in the following steps.

Pre-Requisites

  • An iSCSI Target server
  • iSCSI Target(s) configured on the Target server

Installing The iSCSI Initiator Software

In order to connect to an iSCSI Target server the client requires the iSCSI Initiator Software installed.  To install the iSCSI Initiator Software perform the following steps :-

  1. Logon to the client machine as root
  2. At the command prompt execute yum install iscsi-initiator-utils

iSCSI Chap Credentials Configuration (Optional)

If your iSCSI Target server is configured to require Chap credentials perform the following steps :-

  1. Edit /etc/iscsi/iscsid.conf
  2. Uncomment the line node.session.auth.username = username by removing the # symbol from the start of the line
  3. Change the username to the Chap username required for you iSCSI Target Server
  4. Uncomment the line node.session.auth.password = password by removing the # symbol from the start of the line
  5. Change the password to the Chap password required for you iSCSI Target Server
  6. Uncomment the line discovery.sendtargets.auth.username = username by removing the # symbol from the start of the line
  7. Change the username to the Chap username required for you iSCSI Target Server
  8. Uncomment the line discovery.sendtargets.auth.password = password by removing the # symbol from the start of the line
  9. Change the username to the Chap password required for you iSCSI Target Server
  10. Save and exit the file

Start the iSCSI Service

Once the Chap Credentials have been configured (If required start the iSCSI Service by executing the following step :-

  1. In the command prompt execute service iscsi start

Discover Targets

To discover targets perform the following steps :-

  1. In the command prompt execute iscsiadm -m discovery -t sendtargets -p {iSCSI Target Server IP Address}
  2. Once the iscsiadm command finishes restart the iSCSI Service by executing service iscsi restart

The iscsiadm command will discover any targets available to your client on the network and to see which disks have been found perform the following steps :-

  1. In the command prompt execute fdisk -l

From the list of disks shown by the fdisk command locate the new device(s) which have been added.  For the purposes of this article we’ll use /dev/sdb and /dev/sdc.

N.B. The fdisk will list ALL disks discovered by the iscsiadm command and care must be taken identifying the correct disk to use

Partition And Format The iSCSI Volumes

Once you’ve identified the iSCSI Disk(s) they will need to be formatted and mounted.  To format and mount the disk(s) perform the following steps :-

  1. In the command prompt execute fdisk /dev/sdb
  2. In fdisk type n to create a new partition and press enter
  3. When prompted select the partition type to use from eitherextended or primary and press enter
  4. When prompted select the partition number to use and press enter
  5. To apply the settings to the disk type w and then enter
  6. Repeat steps 1 to 5 for each Disk which requires partitioning

After creating the Partitions on the Disk(s) format them as required.  For the purposes of this article we’ll create an ext3 filesystem.  To create the filesystem on the disks perform the following steps :-

  1. In the command prompt execute mke2fs -j -m 0 -O dir_index /dev/sdb1
  2. Repeat step 1 for each disk which requires a filesystem

Mount The iSCSI Volumes

To mount the disks once they’ve been prepared perform the following steps :-

  1. In the command prompt execute mkdir /mnt/iscsi-disk1 and thenmkdir /mnt/iscsi-disk2
  2. In the command prompt execute mount /dev/sdb1 /mnt/iscsi-disk1 and then mount /dev/sdc1 /mnt/iscsi-disk2

Configure The iSCSI Service To Start Automatically At Boot

To configure the iSCSI Service to start automatically at boot time perform the following step :-

  1. In the command prompt execute chkconfig iscsi on

Automatically Mount The iSCSI Volumes At Boot Time

To configure the iSCSI Volumes to mount at boot time perform the following steps :-

  1. Edit the file /etc/fstab
  2. Add the following lines to the bottom of the file:-

/dev/sdb1    /mnt/iscsi-disk1 ext3 _netdev 0 0

/dev/sdc1    /mnt/iscsi-disk2 ext3 _netdev 0 0

  1. Save and exit the file

Thanks go to the site below which I used to learn how to configure my test server and for further information follow the link below :-

http://www.cyberciti.biz/tips/rhel-centos-fedora-linux-iscsi-howto.html