For When You Can't Have The Real Thing
[ start | index | login ]
start > Linux > iSCSI between CentOS 5 and NetApp OnTap

iSCSI between CentOS 5 and NetApp OnTap

Created by dave. Last edited by dave, 15 years and 130 days ago. Viewed 15,143 times. #3
[diff] [history] [edit] [rdf]


This worked for me with a CentOS 5.2 i386 install against a NetApp 2020 running OnTap

It should probably work for close variations of the above (ie RedHat 5.x, OnTap 7.2.x).

I have the luxury of a segregated network for iSCSI which uses a separate physical interface.


If you have one, configure your secondary NIC with a static IP address to participate on the iSCSI network and plumb your secondary NIC to the iSCSI switch. Make sure the interface is up.

Check for the iscsi initiator utilities:

# rpm -qa | grep -i scsi

We are looking for the "iscsi-initiator-utils" package. So if the above command returns a blank you need to install it

yum install iscsi-initiator-utils

Say yes when prompted unless you see a scary list of Deps that bother you. (In my testing no deps were required.)

Now modify your iqn, you'll need it later when configuring your LUN on the filer for your iGroup. The default iqn looks good but the numbered portion is random so it changes.

# iscsi-iname
Modify the /etc/iscsi/initiatorname.iscsi file and replace the random number with your hostname. The new iSCSI name should look something like this:

If you have one, you need to restrict iscsi to eth1 Poking around google I think the way to do this is defining an iscsi "iface". Let's create the iface config file:

# vi /var/lib/iscsi/ifaces/iface.eth1

iface.transport_name = tcp iface.net_ifacename = eth1

Test the new iface definition

# iscsiadm -m iface
iface.eth1 tcp,default,eth1

Flag iscsi to startup and start iscsi

# chkconfig iscsi on
# service iscsi start

The NetApp bit. We are creating a 1GB iSCSI lun on a 1.1GB volume, inside aggregate myAggr. Note that filers seem to be happiest when 5% to 10% of the volume is free, even if it's going to contain an iSCSI lun. (These numbers are small because this is a test; the largest I've committed is a 250GB LUN into a 265GB volume.)

myFiler> vol create myCentOS_test myAggr 1100m
myFiler> snap reserve myCentOS_test 0
myFiler> vol options myCentOS_test nosnap on
myFiler> vol options myCentOS_test nosnapdir on
myFiler> lun create -s 1000m -t $TYPE /vol/myCentOS_test/lun0
myFiler> igroup create -i -t $TYPE myCentOS
myFiler> lun map /vol/myCentOS_test/lun0 myCentOS 0


  • lun create: $TYPE must be one of: solaris, windows, hpux, aix, linux, netware, vmware or windows_gpt.
  • igroup create: $TYPE must be one of: solaris, windows, hpux, aix, linux netware, or vmware.
Now back on the CentOS system, we discover the targets. My filer's iSCSI address is
iscsiadm --mode discovery --type sendtargets --portal -I default

Important!! If you are restricting your iSCSI traffic to a defined iFace, you must specify it in the discovery mode:

iscsiadm --mode discovery --type sendtargets --portal -I iface.eth1

Restart iscsi

service iscsi restart

And check for new drives

fdisk -l

This noise shows up in my dmesg after partitioning and formatting:

scsi0 : iSCSI Initiator over TCP/IP
  Vendor: NETAPP    Model: LUN               Rev: 0.2
  Type:   Direct-Access                      ANSI SCSI revision: 04
SCSI device sda: 524288000 512-byte hdwr sectors (268435 MB)
sdc: Write Protect is off
sdc: Mode Sense: bd 00 00 08
SCSI device sdc: drive cache: write through
SCSI device sdc: 524288000 512-byte hdwr sectors (268435 MB)
sdc: Write Protect is off
sdc: Mode Sense: bd 00 00 08
SCSI device sdc: drive cache: write through
 sdc: sdc1
sd 0:0:0:0: Attached scsi disk sdc
sd 0:0:0:0: Attached scsi generic sg0 type 0

Once you've partitioned and formatted, you want to add the following line to our fstab file for the above LUN. It tells the computer not to try to mount the filesystem until the network interfaces have started.

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

OK and now the ugliest test of all - init 6 and let's see how this system comes up!

[root@myCentOS ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
                       64G   54G  7.0G  89% /
/dev/sda1              99M   19M   76M  20% /boot
tmpfs                 2.0G     0  2.0G   0% /dev/shm
/dev/sdb1              85G   51G   30G  64% /var/lib/vmware/USB_DataStore
/dev/sdc1             984M   18M  917M   2% /mnt/iscsi

Nice! It's back after a reboot.

If you have two paths to your filer

(Written after the fact)


  • you have more than one interface
  • you have more than one path to the filer (ie the filer is local on both the iSCSI and the LAN networks)
  • the filer is set to talk iSCSI on all interfaces that you'd hit it on
… you'll likely end up with multiple connections to the same LUN.

To fix, define the iFace as above, then go look in /var/lib/iscsi/nodes, and delete the directories named with the LUNs mounted through the wrong path. Then reboot, and it should only mount the remaining LUN path.

no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful: | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt