Internet SCSI (iSCSI) is a network protocol s 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 Volume under Linux. It allows access to SAN storage over Ethernet.
Open-iSCSI Project
Open-iSCSI project is a high-performance, transport independent, multi-platform implementation of iSCSI. Open-iSCSI is partitioned into user and kernel parts.
Instructions are tested on:
[a] RHEL 5
[b] CentOS 5
[c] Fedora 7
[d] Debian / Ubuntu Linux
Install Required Package
iscsi-initiator-utils RPM package - The iscsi package provides the server daemon for the iSCSI protocol, as well as the utility programs used to manage it. iSCSI is a protocol for distributed disk access using SCSI commands sent over Internet Protocol networks. This package is available under Redhat Enterprise Linux / CentOS / Fedora Linux and can be installed using yum command:
# yum install iscsi-initiator-utils
A note about Debian / Ubuntu Linux
If you are using Debian / Ubuntu Linux install open-iscsi package, enter:
$ sudo apt-get install open-iscsi
iSCSI Configuration
There are three steps needed to set up a system to use iSCSI storage:
- iSCSI startup using the init script or manual startup. You need to edit and configure iSCSI via /etc/iscsi/iscsid.conf file
- Discover targets.
- Automate target logins for future system reboots.
- You also need to obtain iSCSI username, password and storage server IP address (target host)
Step # 1: Configure iSCSI
Open /etc/iscsi/iscsid.conf with vi text editor:
# vi /etc/iscsi/iscsid.conf
Setup username and password:
node.session.auth.username = My_ISCSI_USR_NAME
node.session.auth.password = MyPassword
discovery.sendtargets.auth.username = My_ISCSI_USR_NAME
discovery.sendtargets.auth.password = MyPassword
Where,
- node.session.* is used to set a CHAP username and password for initiator authentication by the target(s).
- discovery.sendtargets.* is used to set a discovery session CHAP username and password for the initiator authentication by the target(s)
You may also need to tweak and set other options. Refer to man page for more information. Now start the iscsi service:
# /etc/init.d/iscsi start
Step # 2: Discover targets
Now use iscsiadm command, which is a 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 restart
Now there should be a block device under /dev directory. To obtain new device name, type:
# fdisk -l
or
# tail -f /var/log/messages
Output:
Oct 10 12:42:20 ora9is2 kernel: Vendor: EQLOGIC Model: 100E-00 Rev: 3.2
Oct 10 12:42:20 ora9is2 kernel: Type: Direct-Access ANSI SCSI revision: 05
Oct 10 12:42:20 ora9is2 kernel: SCSI device sdd: 41963520 512-byte hdwr sectors (21485 MB)
Oct 10 12:42:20 ora9is2 kernel: sdd: Write Protect is off
Oct 10 12:42:20 ora9is2 kernel: SCSI device sdd: drive cache: write through
Oct 10 12:42:20 ora9is2 kernel: SCSI device sdd: 41963520 512-byte hdwr sectors (21485 MB)
Oct 10 12:42:20 ora9is2 kernel: sdd: Write Protect is off
Oct 10 12:42:20 ora9is2 kernel: SCSI device sdd: drive cache: write through
Oct 10 12:42:20 ora9is2 kernel: sdd: unknown partition table
Oct 10 12:42:20 ora9is2 kernel: sd 3:0:0:0: Attached scsi disk sdd
Oct 10 12:42:20 ora9is2 kernel: sd 3:0:0:0: Attached scsi generic sg3 type 0
Oct 10 12:42:20 ora9is2 kernel: rtc: lost some interrupts at 2048Hz.
Oct 10 12:42:20 ora9is2 iscsid: connection0:0 is operational now
/dev/sdd is my new block device.
Step # 3: Format and Mount iSCSI Volume
You can now partition and create a filesystem on the target using usual fdisk and mkfs.ext3 commands:
# fdisk /dev/sdd
# mke2fs -j -m 0 -O dir_index /dev/sdd1
OR
# mkfs.ext3 /dev/sdd1
Tip: If your volume is large size like 1TB, run mkfs.ext3 in background using nohup:
# nohup mkfs.ext3 /dev/sdd1 &
Mount new partition:
# mkdir /mnt/iscsi
# mount /dev/sdd1 /mnt/iscsi
Step #4: Mount iSCSI drive automatically at boot time
First make sure iscsi service turned on at boot time:
# chkconfig iscsi on
Open /etc/fstab file and append config directive:
/dev/sdd1 /mnt/iscsi ext3 _netdev 0 0
Save and close the file.
Further readings:
- Official Open iSCSI documentation
- Read iscsiadm and related man pages
Continue reading rest of the Linux iSCSI Storage Configuration series.
Contents
- CentOS / Red Hat Linux: Install and manage iSCSI Volume
- CentOS 4 / Redhat Enterprise Linux 4 iSCSI Installation and Configuration ( iscsi initiators )
- How To: Windows Server / XP / 2000 / 2003 ISCSI Initiator Configuration
- Linux tgtadm: Setup iSCSI Target ( SAN )
- Red Hat / CentOS Linux 4: Setup Device Mapper Multipathing
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- 10 Greatest Open Source Software Of 2009
- My 10 UNIX Command Line Mistakes
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
- Email this to a friend
- Download PDF version
- Printable version
- Comment RSS feed
- Last Updated: May/13/2008



{ 25 comments… read them below or add one }
IT is very good and keepit up
I am trying according to your document and run these steps and found these errors.
any good solution?
# /etc/init.d/iscsi start
Checking iscsi [ OK ]
Loading iscsi driver: FATAL: Module iscsi_sfnet not found. [FAILED]
#/sbin/iscsi-ls -l
iSCSI driver is not loaded
to reach ‘iscsi_sfnet’ you try to start first ‘iscsid’
bye
hiya, well done, thanks.
Works perfect with Scientific Linux 5 (32 and 64 bit) and MSA 2012i, I just used xfs for my instalation.
cheers/zdrowka!
When I run isciadmin i get the following error. Help !
10.42.40.198 is the ip address of the server running iscsi and iscsid.
—
[root@swt60p iscsi]# iscsiadm -m discovery -t sendtargets -p 10.42.40.198
iscsiadm: cannot make connection to 10.42.40.198:3260 (111)
iscsiadm: connection to discovery address 10.42.40.198 failed
iscsiadm: cannot make connection to 10.42.40.198:3260 (111)
iscsiadm: connection to discovery address 10.42.40.198 failed
iscsiadm: cannot make connection to 10.42.40.198:3260 (111)
iscsiadm: connection to discovery address 10.42.40.198 failed
–
Paras.
Perfect solution. Got my Fedora 9 workstation talking to my openfiler server in no time at all. Many thanks.
Thanks, It works so nice on RHEL 5.2
But I think it’s better to do;
mkfs.ext3 /dev/sdd1 &>somelog & disown
Than;
nohup mkfs.ext3 /dev/sdd1 &
How do you tell which targets are associated with which device? The discovery process found both iscsi targets on the zfs server I’m using and want to make sure I’m making a new filesystem on the right one…
I got the same error as Paras Pradhan. Any solution to that?
Robert,
Make sure firewall is not blocking connection.
Robert and Paras: Is a network ACL installed at the ISCSI target system?
Is the connection working proper? If your useing for example openfiler as your
target system check the status of the connection by useing: “netcat -an | grep “3260″ ” you will see the remote system is trying to connect to your filer.
Or you can add a hig debug-level to you iscsiadm command:
iscsiadm -d 9 -m discovery -t sendtargets -p 192.168.1.5
Bjoern
simple and fast.. thanks a lot
You can also label the devices this way if they change or are renamed etc on reboot you will be mounting by label and not device name.
e2label on the /dev/vg/lv
eg
e2label e2label /dev/vg4/lv4 /home4
The in etc/fstab
LABEL=/home4 /home4 ext3 _netdev 0 0
Is there a howto to get this installed at OS install time? Interested in seeing if it could be done
Great Guide, wanted to say thanks. This saved me god knows how many hours of research. Also wanted to point out a great unti
lshwWhich can be install using
yum isntall lshwthis makes it about 100 times easyer to find the new device name
Little note: “netfs” service must be on in chkconfig in red-hat, else the mountpoints are not mounted.
i’m not sure
…about what?
Thanks for the guide,
Maybe stupid question, but i don’t undertand where i can find or set initiator name? Or i don’t need it? What should i set on storage site?
Thank you,
Jap
sorry, it is there :-]
/etc/iscsi/initiatorname.iscsi
stujap
Robert and Paras, you probably get this error because iscsi and iscsid is not started on your client nodes, reboot those (or use service iscsi start; service iscsid start) and you will be able to discover your devices.
I had the same error, chkconfig showed me that they were on – but a reboot of the clients solved my problems
Good job !!!
But when i check my fs on my das this is the result :
real 0m24.005s
user 0m0.000s
sys 0m0.000s
##########
0+10 enregistrements lus.
0+10 enregistrements écrits.
real 0m0.001s
user 0m0.000s
sys 0m0.001s
##########
0+10 enregistrements lus.
0+10 enregistrements écrits.
real 0m0.001s
user 0m0.000s
sys 0m0.001s
##########
0+9 enregistrements lus.
0+9 enregistrements écrits.
real 0m0.535s
user 0m0.000s
sys 0m0.001s
I do not know why sometime the response time is very long
Thx
Great article and well written!
Very easy to follow and use.
I was able to mount and use the device but after stopping the iscsi service and unmounting the device, I wasn’t able to mount it again.
additional:
This is how it looks like when I issue fdisk -l
Disk /dev/sdn: 143.0 GB, 143034155008 bytes
255 heads, 63 sectors/track, 17389 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdn1 1 17389 139677111 83 Linux
Disk /dev/sdn1: 143.0 GB, 143029361664 bytes
255 heads, 63 sectors/track, 17388 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdn1 doesn’t contain a valid partition table
Disk /dev/sdo: 968.0 GB, 968016265216 bytes
255 heads, 63 sectors/track, 117687 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdo1 1 117687 945320796 83 Linux
The one with the problem is /dev/sdo1. I’m expecting it to be looked like sdn1.
(sdo1 and sdn1 are partition of sdo and sdn device).
I am using rhel 4 AS, 2.6.9-42ELsmp,
iscsitarget-kernel-smp-0.4.12-6_2.6.9_42.EL
iscsitarget-0.4.12-6
iscsi-initiator-utils-4.0.3.0-4
Regards,
Jay A