ISCSI Setting up an Initiator

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

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).

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).

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!

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

        

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

        

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.

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!

A word about initiator device paths on Linux

There are 2 paths avalible for use, the standard Linux block device (ie: /dev/sdx, /dev/sdx1, etc) and the iSCSI device path (the /dev/iscsi tree). The devices in the iSCSI tree are just symlinks back to the standard Linux paths, however the iSCSI paths provide more clarity which is useful for troubleshooting. Specifically, because the iSCSI commands shown above do not report the Linux block device name, they do however show the bus number, target id, and lun. An iSCSI device path looks like this:

[root@nexus /]# ls -l /dev/iscsi/bus0/target0/lun0

total 0

lrwxrwxrwx    1 root     root            8 Apr 13 12:25 disk -> /dev/sdh

lrwxrwxrwx    1 root     root            8 Apr 13 12:25 generic -> /dev/sg7

lrwxrwxrwx    1 root     root            9 Apr 13 12:25 part1 -> /dev/sdh1

In this tutorial I have utilized the Linux block device name instead of the full iSCSI device path primarily due to formatting concerns (iSCSI paths run off the page). I do not recommend that you use the Linux block device directly for any reason. Failuring to utilize the iSCSI paths will only create confusion and impair troubleshooting.

Notes for using a Linux Initiator with NetApp Filer Targets

If you expect to use the initiator to connect to a NetApp Filer at some point you will need to add some extra parameters to your /etc/iscsi.conf. Here is the configuration file I use for connecting to a NetApp 840 Filer:

Username=benr

Password=nopassneeded

### NetApp 940 iSCSI Portal

DiscoveryAddress=10.10.2.240

### These lines are required for NetApp Filers

### If you do not add them you will not beable

###  to communicate with the filer!

Continuous=no

HeaderDigest=never

DataDigest=never

ImmediateData=yes

        

If the four parameters listed here are not present you’ll get all sorts of strange timeouts and warning, and you’ll even connect but never be able to access the LUNs. For further information about iSCSI on NetApp Filers, head over to now.netapp.com.

서진우

슈퍼컴퓨팅 전문 기업 클루닉스/ 상무(기술이사)/ 정보시스템감리사/ 시스존 블로그 운영자

You may also like...

페이스북/트위트/구글 계정으로 댓글 가능합니다.