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 :-
- Logon to the client machine as root
- 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 :-
- Edit /etc/iscsi/iscsid.conf
- Uncomment the line node.session.auth.username = username by removing the # symbol from the start of the line
- Change the username to the Chap username required for you iSCSI Target Server
- Uncomment the line node.session.auth.password = password by removing the # symbol from the start of the line
- Change the password to the Chap password required for you iSCSI Target Server
- Uncomment the line discovery.sendtargets.auth.username = username by removing the # symbol from the start of the line
- Change the username to the Chap username required for you iSCSI Target Server
- Uncomment the line discovery.sendtargets.auth.password = password by removing the # symbol from the start of the line
- Change the username to the Chap password required for you iSCSI Target Server
- 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 :-
- In the command prompt execute service iscsi start
Discover Targets
To discover targets perform the following steps :-
- In the command prompt execute iscsiadm -m discovery -t sendtargets -p {iSCSI Target Server IP Address}
- 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 :-
- 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 :-
- In the command prompt execute fdisk /dev/sdb
- In fdisk type n to create a new partition and press enter
- When prompted select the partition type to use from eitherextended or primary and press enter
- When prompted select the partition number to use and press enter
- To apply the settings to the disk type w and then enter
- 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 :-
- In the command prompt execute mke2fs -j -m 0 -O dir_index /dev/sdb1
- 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 :-
- In the command prompt execute mkdir /mnt/iscsi-disk1 and thenmkdir /mnt/iscsi-disk2
- 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 :-
- 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 :-
- Edit the file /etc/fstab
- 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
- 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