Setting up an Initiator

The Linux-iSCSI Proejct provides a driver, daemon, and tools for their iSCSI software initiator. This project is the Open Source version of the Cisco iSCSI driver intended for use with the Cisco SN 5428-2 Storage Router, but can be used with any iSCSI target. This driver is also available in a closed form for Solaris and HP-UX from Cisco.

The following are the steps to set up a software initiator.

Procedure 2. Setting up an iSCSI Initiator

  1. Download the appropriate tarball from http://sourceforge.net/project/showfiles.php?group_id=26396. Make sure that the version you download corresponds with the kernel you are using, otherwise you'll have all types of strange problems. If you are also running an iSCSI target on this system you'll want to use the 2.4 Production Source (3.4.2 as of this writing).

  2. Untar the source tarball and edit the Makefile. Change KERNEL_CONFIG and TOPDIR to match the location of your kernel source tree if your kernel tree isn't in the "usual place" (/usr/src/linux).

  3. Compile the source with "make" and then as root install with "make install". This will install all the tools, daemons, init script, sample config file, and modules into place.

    [root@nexus linux-iscsi-3.4.2]# make install
    
    Note: using kernel source from /lib/modules/2.4.22/build containing
    kernel version 2.4.22
    
    Note: using kernel config from /lib/modules/2.4.22/build/.config
    
    Installing iSCSI driver for Linux 2.4.22
    
    The initialization script has been installed as /etc/rc.d/init.d/iscsi.
    
    iSCSI has been set up to run automatically when you reboot.
    
    InitiatorName iqn.1987-05.com.cisco:01.9c871ac985a was generated and
    written to /etc/initiatorname.iscsi.
    
    Make sure you check and edit the /etc/iscsi.conf file!
    
  4. Edit your /etc/iscsi.conf. If you aren't sure how to configure your initiator you can specify any username and password (assuming your not using authentication on your target) and use the DiscoveryAddress keyword to define an address to discover. If you created a target on this machine, specify it's address to discover.

    [root@nexus /etc]# cat iscsi.conf
    Username=benr
    Password=fakepass
    
    DiscoveryAddress=10.10.1.100
      Username=benr
      Password=somepass
    	
  5. Now start the initiator using the RC script. Watch syslog (tail -f /var/log/messages) while you do this.

    [root@nexus /]# /etc/init.d/iscsi start 
    Starting iSCSI: iscsi iscsid fsck/mount
    [root@nexus /]# 
    	

    My syslog output is below. You may see errors and warnings during the startup, I have removed warnings and dates from the output below for clarity.

    [root@nexus /]# tail -f /var/log/messages
    
    iscsid[30112]: version 3.4.2 (16-Feb-2004) 
    iscsid[30112]: INBP boot check returned this_is_inbp_boot = 0 
    kernel: iSCSI: bus 0 target 1 = iqn.1997-06.com.homestead:storage.disk2.drew
    kernel: iSCSI: bus 0 target 1 portal 0 = address 10.10.1.100 port 3260 group 1
    kernel: iSCSI: bus 0 target 1 trying to establish session df2dc000 to portal 0, 
    	address 10.10.1.100 port 3260 group 1
    kernel: iSCSI: bus 0 target 1 established session df2dc000 #1, portal 0, 
    	address 10.10.1.100 port 3260 group 1
    kernel: iSCSI: bus 0 target 0 = iqn.1997-06.com.homestead:storage.disk1.nexus
    kernel: iSCSI: bus 0 target 0 portal 0 = address 10.10.1.100 port 3260 group 1
    kernel: iSCSI: bus 0 target 0 trying to establish session ca4ee000 to portal 0, 
    	address 10.10.1.100 port 3260 group 1
    kernel: iSCSI: bus 0 target 0 established session ca4ee000 #1, portal 0, 
    	address 10.10.1.100 port 3260 group 1
    kernel: scsi singledevice 1 0 0 0
    kernel:   Vendor: LINUX     Model: ISCSI             Rev: 0   
    kernel:   Type:   Direct-Access                      ANSI SCSI revision: 03
    kernel: Attached scsi disk sdh at scsi1, channel 0, id 0, lun 0
    kernel: SCSI device sdh: 35566480 512-byte hdwr sectors (18210 MB)
    kernel:  sdh: unknown partition table
    kernel: scsi singledevice 1 0 1 0
    kernel:   Vendor: LINUX     Model: ISCSI             Rev: 0   
    kernel:   Type:   Direct-Access                      ANSI SCSI revision: 03
    kernel: Attached scsi disk sdi at scsi1, channel 0, id 1, lun 0
    kernel: SCSI device sdi: 35566480 512-byte hdwr sectors (18210 MB)
    kernel:  sdi: sdi1
    	
  6. If everything goes properly, your initiator should have auto-discovered the targets from your target daemon. You can use the command "iscsi-ls" to see which targets your connected to.

    [root@nexus /]# iscsi-ls 
    *************************************************************************
            Cisco iSCSI Driver Version ... 3.4.2 (16-Feb-2004 )
    *************************************************************************
    TARGET NAME             : iqn.1997-06.com.homestead:storage.disk1.nexus
    TARGET ALIAS            : 
    HOST NO                 : 1 
    BUS NO                  : 0 
    TARGET ID               : 0 
    TARGET ADDRESS          : 10.10.1.100:3260
    SESSION STATUS          : ESTABLISHED AT Mon Apr 12 15:13:32 2004
    NO. OF PORTALS          : 1 
    PORTAL ADDRESS 1        : 10.10.1.100:3260,1
    SESSION ID              : ISID 00023d000001 TSID 100
    *************************************************************************
    TARGET NAME             : iqn.1997-06.com.homestead:storage.disk2.drew
    TARGET ALIAS            : 
    HOST NO                 : 1 
    BUS NO                  : 0 
    TARGET ID               : 1 
    TARGET ADDRESS          : 10.10.1.100:3260
    SESSION STATUS          : ESTABLISHED AT Mon Apr 12 15:13:32 2004
    NO. OF PORTALS          : 1 
    PORTAL ADDRESS 1        : 10.10.1.100:3260,1
    SESSION ID              : ISID 00023d000001 TSID 100
    *************************************************************************
    [root@nexus /]#
    	

    You'll notice in the above output that these 2 targets are using the names I defined in the Target daemon config file.

  7. You can now partition and create a filesystem on the target in the usual ways. Use the syslog output to figure out the mapping from iSCSI target to Linux device name.

    [root@nexus /]# fdisk /dev/sdh
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-17366, default 1): 
    Using default value 1
    Last cylinder or +size or +sizeM or +sizeK (1-17366, default 17366): 
    Using default value 17366
    
    Command (m for help): p
    
    Disk /dev/sdh: 64 heads, 32 sectors, 17366 cylinders
    Units = cylinders of 2048 * 512 bytes
    
       Device Boot    Start       End    Blocks   Id  System
    /dev/sdh1             1     17366  17782768   83  Linux
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    
    WARNING: If you have created or modified any DOS 6.x
    partitions, please see the fdisk manual page for additional
    information.
    Syncing disks.
    [root@nexus /]# mkfs -t jfs /dev/sdh1
    mkfs.jfs version 1.1.0, 20-Nov-2002
    Warning!  All data on device /dev/sdh1 will be lost!
    
    Continue? (Y/N) y
       \
    
    Format completed successfully.
    
    17782768 kilobytes total disk space.
    [root@nexus /]# mount -t jfs /dev/sdh1 /iscsi
    [root@nexus /]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/hda1             4.8G  4.3G  286M  94% /
    /dev/hda5              13G   11G  2.0G  85% /home
    /dev/sdh1              17G  2.3M   16G   1% /iscsi
    [root@nexus /]# 
    	

This should get your target mounted and ready to use!