Reference Section
-
Setup an iSCSI Initiator
Brief article that summarises most of what this page covers. -
Linux Open-iSCSI Initiator
In-depth reference article. -
Open-iSCSI and SUSE Linux
In-depth reference article, not quite the same as our iscsi-inititor-utils package but still very helpful. -
MAN page of iscsi.conf
As it says on the tin, the core configuration file manual page.
What this article will cover
- Installation of the iSCSI client software, iscsi initiator utils, on a Fedora 8 server
- Connection to an EMC SAN via iSCSI and discovery of LUNS
- Configuration of the iSCSI client software to mount two preconfigured iSCSI LUNS on an EMC SAN.
What this article assumes
- You have root access to your Fedora system (naturally)
- iSCSI LUNS have been made available to your Fedora system on the SAN
(This is covered fully elsewhere but is briefly touched upon here too)
1. Connection to the Fedora 8 Server (fedora.mydept)
Key Facts
Our Server: fedora.mydept.ac.uk (abbrev. fedora)
Server OS: Fedora 8
LAN: eth0 - IP: 137.195.x.y
Server Login: melogin
SSL & Configuring the Fedora Environment
(You may wish to jump straight to the next section which deals with installing the iSCSI client software).
Access to the server is via SSL from a Windows XP host.
- On the XP host, download and install the freeware PuTTY SSL client.
- Use PuTTY (putty.exe) to connect to fedora via SSH.
- Login as user account melogin.
Check the Linux environment and configure according to one's taste:
- Edit the .bashrc file to create some useful aliases:
fedora> vi .bashrc
and enter
alias ls-'ls -F'
[vi reminder: "i" = Insert mode, :w writes file, :q quits, ESC exits a mode]
- As vi is not everyone's cup of tea, one may use the PSFTP (PuTTY Secure FTP) executable to transfer a single binary of
the nanoemacs (ne) editor to the server.
- Start PSFTP (it asks for the host to connect to) and login as melogin.
- Check the local and remote working directories:
> lwd
C:/
> pwd
/u1/others/melogin
- Copy the ne binary from the root of C:\ on the XP host to the Fedora machine:
> put ne > quit
- Using PuTTY and SSH, login to the Fedora machine, perform an lroot, then move & rename the binary:
> su -lroot > cp /u1/others/melogin/ne /sbin > chmod a+rx /sbin/ne > mv /sbin/ne /sbin/ue
Why rename the binary? Only because the author is familiar with issuing the ue (microemacs) command and for basic editing, there's no difference between the nano and micro versions of the software.
- Let us examine the current disk environment:
fedora> df -h Device Capacity Use Mount /dev/sda1 29G 53% / /dev/sda2 29G 2% /var /dev/sda5 137G 1% /data0 /dev/sda6 137G 1% /data1 /dev/sda7 137G 1% /data2 tmpfs 2G 1% /dev/shm
- Now change to root and check out the shell environment:
fedora> su -lroot [root@fedora~#] [root@fedora~#] pwd
/root
[root@fedora~#]
Check the PATH environment variable as sometimes, on Fedora, this excludes /sbin:
[root@fedora~#] printenv PATH
(affirm that it does contain /sbin)
Finally, check the OS version:
[root@fedora~#] uname -r
2.6.25.14_69.fc8
2. Obtain and install the iSCSI Initiator Utils Package
The package named iSCSI Initiator Utils permits iSCSI client access for Linux systems to iSCSI Targets.
- First, check if it this package is already installed:
[root@fedora~#] rpm -q iscsi-initiator-utils
(nothing found)
- Search for the package with YUM, hoping it resides in a Fedora repository:
[root@fedora~#] yum search iscsi-initiator-utils
iscsi-initiator-utils.x86_64
One can check the version from http://www.rpmfind.net - indeed, this is the appropriate version.
- Install the package using YUM:
[root@fedora~#] yum -y install iscsi-initiator-utils
Installed! iscsi-initiator-utils.x86_64 0.6.2.0.865-0.2.fc8
3. Configure the iSCSI Initiator Utils Package
There are four main things to know about the iSCSI Initiator Utils package.
- It runs as a service named iscsi
- It is controlled by the iscsiadm command.
- The service has configuration files under /etc/iscsi
- The service stores information about iSCSI targets under /var/lib/iscsi
- Let us check the service configuration files, the startup and running status of the iSCSI service:
[root@fedora~#] cd /etc/iscsi [root@fedora~#] ls
iscsid.conf
initiatorname.iscsi
[root@fedora~#]
[root@fedora~#] chkconfig --list | grep iscsi
(service iscsi and iscsid are ON for runlevels 3,4 & 5)
[root@fedora~#]
[root@fedora~#] service iscsi status
service iscsi is stopped
[root@fedora~#]
[root@fedora~#] service iscsid status
service iscsid is stopped
Observe that there are two services, iscsi and iscsid, but one is believed to be an alias of the other.
After installation, neither is running, which is good because we have some configuration to perform. - The iscsi service will identify this server via a unique, but user changeable, name called the iscsi initiator name.
Open configuration file /etc/iscsi/initiatorname.iscsi in an editor of your choice
[root@fedora~#] ue /etc/iscsi/iscsi/initiatorname.iscsi
Locate the line starting with InitiatorName=
The last portion of this line, that which follows the colon, may be editied so as to provide a more human-readable identifier for this iSCSI client which is something we will need shortly.For our Fedora server the line was edited to look as follows:
InitiatorName=iqn.2005-03.org.open-iscsi:fedora001
- Now we require to edit the other configuration file, /etc/iscsi/iscsid.conf, to incorporate information
on this iSCSI initiator name and the remote iSCSI system to which we wish to connect.
A word of clarification: iSCSI Target
When configuring an iSCSI SAN, the term Target refers to a collection of LUNS on the SAN which some remote client (Linux server) wishes to connect with. However, when we are talking about the iscsi initiator utils package, the term target refers to the iSCSI initiator name. (Or do I have this very wrong?)Open /etc/iscsi/iscsid.conf in an editor and add the two lines shown:
[root@fedora~#] cd /etc/iscsi [root@fedora~#] ue /etc/iscsi/iscsid.conf DiscoveryAddress=137.195.a.b:3260 TargetName=iqn.2005-03.org.open-iscsi:fedora001
The DiscoveryAddress should be the IP and port number (default: 3260) of the iSCSI Target on the SAN. Here the actual IP address has been hidden for security, you would substitute your own Celerra IP address here, naturally.
The TargetName is actually the iSCSI Initiator name on our Fedora server - but I do need to check that, be careful, these notes are incomplete.
4. Discovery of, and login to, iSCSI SAN Targets
So, the iSCSI initiator utils package has been installed, the service is not running, and all the configuration has been completed on the Linux end. Only four steps remain:
- Start the iSCSI service on Fedora
- Query the iSCSI SAN for available iSCSI Targets (collections of LUNS)
- Connect to the above available LUNS (a process termed 'logging in' which may involve CHAPS authentication)
- Mount the LUNS
Before doing any of this, we must configure the SAN to allow connection from this Fedora host.
This brief operation is covered in the four Highslide-enabled graphics below.
In the example screens here we have a Celerra iSCSI Target with the name iSCSI_macs to which we wish to connect our Fedora server.
Now that the SAN will permit access from our iSCSI client software, there are two steps involved in connection to the SAN: discovery of iSCSI targets, and login to those targets. It is useful to establish an alias for the commands used as they're quite involved.
- Create useful alias entries.
As root, create the following alias entries in .bashrc (here with the microemacs editor, you could use vi just as easily):
Below, IP number 137.195.a.b represents the Celerra SAN (replace with the IP number for your own SAN, naturally).[root@fedora~#] cd /root [root@fedora~#] ue .bashrc alias is-discovery='iscsiadm -m discovery -t sendtargets -p 137.195.a.b:3260' alias is-login='iscsiadm -m mode -t iqn.1992-05.com.emc:ck2000629002240000-2 -p 137.195.a.b -l' alias is-logout='iscsiadmin -m node --logoutall=all' [root@fedora~#] [root@fedora~#] . /.bashrc
Here, t stands for iSCSI Target and p is the iSCSI portal of the SAN.
The portal represents an ethernet device (either physical or logical on the SAN) inside of which we may think of a number of iSCSI Targets as residing. One portal (ethernet device) may represent a single gateway to a number of Celerra systems connected together, inside of which multiple iSCSI targets may have been created. This is why we have both a portal and a target, and not just one or the other. - Start the iSCSI service
[root@fedora~#] service iscsi start [root@fedora~#] service iscsi status
service iscsi is running
- Perform iSCSI discovery of Targets using the above alias:
[root@fedora~#] is-discovery
137.195.a.b.3260,1 iqn.1992-05.com.emc:ck2000629002240000-2
- Login to the above iSCSI targets. In this configuration no CHAPS passwords have been set for simplicity.
[root@fedora~#] is-login
- If the login went well, we should have two new iSCSI LUNS presenting themselves as local disks.
Let's check - recall that before, we had only /dev/sda.[root@fedora~#] fdisk -l /dev/sda /dev/sdb /dev/sdb1 /dev/sdc /dec/sdc1
The devices /dev/sdb1 and /dev/sdc1 are are two iSCSI LUNS.
- Importantly, we sometimes need to know how to dismount these LUNS, which is performed by logging out of the iSCSI session as follows:
[root@fedora~#] iscsiadmin -m node --logoutall=all
5. Mounting the iSCSI LUNS
Now that we have discovered and logged-in to the iSCSI SAN, we wish to mount the LUNS. There is one thing to remember.
- The iSCSI service may not discover the LUNS in the order one imagines.
Consequently what is /dev/sdb1 on one day may be /dev/sdc1 on another.
We get around this by using disk labels. A disk label stays with a disk (or LUN) no matter which system may mount it.
-
Once we have our LUNS available, we label them as follows:
[root@fedora~#] tune2fs -L mylun1 /dev/sdb1 [root@fedora~#] tune2fs -L mylun2 /dev/sdc1
One needs do this only once (it has been done for the two iSCSI LUNS created for MACS to this point).
- Create mount points for the LUNS. Here we creat mount points under /mnt:
[root@fedora~#] cd /mnt [root@fedora~#] mkdir /mnt/sdb [root@fedora~#] mkdir /mnt/sdc
- Edit /etc/fstab and specify that mounting be done by label.
The _netdev ensures that the network service has started before any attempt to mount a device is made:[root@fedora~#] ue /etc/fstab #device mountpoint Filesys Options backup fsck LABEL=mylun1 /mnt/sdb ext3 _netdev 0 0 LABEL=mylun2 /mnt/sdc ext3 _netdev 0 0
Now mount all _netdev devices:
[root@fedora~#] mount -a -t _netdev
The mount should now persist across reboots.



