In this article, we set up an iSCSI target for the 2.4 linux kernel. Development for the 2.4 kernel, at least with the iSCSI target we are using has ceased, so we needed move to 2.6. In this article, we will set up an iSCSI target using the latest and greatest iSCSI target software available from here. We are using version 0.4.13. The system we are using this on is a minimal Linux From Scratch (LFS) GNU/Linux system. The main reason for this was to keep from depending on distribution customizations. Althought there are a lot of features using Red Hat Enterprise that are useful, it is also good to see how to do this with just some source code tarballs. We are using a 2.6.17 Linux kernel:
# uname -a Linux sv-1 2.6.17.1 #1 SMP PREEMPT Mon Jun 26 04:01:27 PDT 2006 i686 pentium4 i386 GNU/Linux |
Let’s extract and compile:
# tar -xzf iscsitarget-0.4.13.tar.gz # cd iscsitarget-0.4.13 # make KERNELSRC=../linux-2.6.17.1 make -C usr make[1]: Entering directory `/usr/src/iscsitarget-0.4.13/usr' cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -c -o ietd.o ietd.c . . . LD [M] /usr/src/iscsitarget-0.4.13/kernel/iscsi_trgt.o Building modules, stage 2. MODPOST CC /usr/src/iscsitarget-0.4.13/kernel/iscsi_trgt.mod.o LD [M] /usr/src/iscsitarget-0.4.13/kernel/iscsi_trgt.ko make[1]: Leaving directory `/usr/src/linux-2.6.17.1' # |
Copy the configuration file and make a symbolic link so that the init script will install correctly (do this only when needed, as is the case with our LFS system):
# cp etc/ietd.conf /etc # # ln -s /etc/rc.d/init.d /etc/init.d |
Install:
# make KERNELSRC=../linux-2.6.17.1 install `usr/ietd' -> `/usr/sbin/ietd' `usr/ietadm' -> `/usr/sbin/ietadm' if [ -f /etc/debian_version ]; then \ install -vD -m 755 etc/initd/initd.debian /etc/init.d/iscsi-target; \ elif [ -f /etc/redhat-release ]; then \ install -vD -m 755 etc/initd/initd.redhat /etc/init.d/iscsi-target; \ elif [ -f /etc/gentoo-release ]; then \ install -vD -m 755 etc/initd/initd.gentoo /etc/init.d/iscsi-target; \ elif [ -f /etc/slackware-version ]; then \ install -vD -m 755 etc/initd/initd /etc/rc.d/iscsi-target; \ else \ install -vD -m 755 etc/initd/initd /etc/init.d/iscsi-target; \ fi `etc/initd/initd' -> `/etc/init.d/iscsi-target' install: creating directory `/lib/modules/2.6.17.1/kernel/iscsi' `kernel/iscsi_trgt.ko' -> `/lib/modules/2.6.17.1/kernel/iscsi/iscsi_trgt.ko' depmod -aq # |
Here is how we set up /etc/ietd.conf:
Target iqn.2006-06.com.signalq:storage.lvm Lun 0 Path=/dev/hdb,Type=fileio MaxConnections 1 InitialR2T Yes ImmediateData No MaxRecvDataSegmentLength 256 MaxXmitDataSegmentLength 256 MaxBurstLength 256 FirstBurstLength 256 DefaultTime2Wait 2 DefaultTime2Retain 20 MaxOutstandingR2T 1 DataPDUInOrder Yes DataSequenceInOrder Yes ErrorRecoveryLevel 0 HeaderDigest CRC32C DataDigest CRC32C various target parameters Wthreads 8 Alias LVMVOL |
Note that this is really crippled as far as the sizes of transfers. It made the system much more usable and stable for our Mac OS X Initiator we are using over a slow network connection (see this article). Start up the target:
# /etc/init.d/iscsi-target start # tail /var/log/sys.log Jun 26 14:15:29 sv-1 udev[3221]: creating device node '/dev/vcs4' Jun 26 14:15:29 sv-1 udev[3243]: creating device node '/dev/vcs6' Jun 26 14:15:29 sv-1 udev[3256]: creating device node '/dev/vcsa4' Jun 26 14:15:29 sv-1 udev[3257]: creating device node '/dev/vcsa6' Jun 26 14:15:29 sv-1 udev[3278]: creating device node '/dev/vcs5' Jun 26 14:15:29 sv-1 udev[3279]: creating device node '/dev/vcsa5' Jun 26 14:16:44 sv-1 kernel: iSCSI Enterprise Target Software - version 0.4.13 Jun 26 14:16:44 sv-1 kernel: iotype_init(90) register fileio Jun 26 14:16:44 sv-1 kernel: iotype_init(90) register nullio Jun 26 14:16:44 sv-1 iscsid: unable to create server socket (Address family not supported by protocol) 10 1 6! |
We are using IPV4. The server works fine, though, and the processes all start up OK:
# ps -ef . . . root 3315 3123 0 14:16 ? 00:00:00 sshd: root@ttyp0 root 3319 3315 0 14:16 ttyp0 00:00:00 -bash root 3339 1 0 14:16 ? 00:00:00 /usr/sbin/ietd root 3340 6 0 14:16 ? 00:00:00 [istd1] root 3341 6 0 14:16 ? 00:00:00 [istiod1] root 3342 6 0 14:16 ? 00:00:00 [istiod1] root 3343 6 0 14:16 ? 00:00:00 [istiod1] root 3344 6 0 14:16 ? 00:00:00 [istiod1] root 3345 6 0 14:16 ? 00:00:00 [istiod1] root 3346 6 0 14:16 ? 00:00:00 [istiod1] root 3347 6 0 14:16 ? 00:00:00 [istiod1] root 3348 6 0 14:16 ? 00:00:00 [istiod1] # cat /proc/net/iet/volume tid:4 name:iqn.2006-06.com.signalq:storage.lvm lun:0 state:0 iotype:fileio path:/dev/hdb # # cat /proc/net/iet/session tid:4 name:iqn.2006-06.com.signalq:storage.lvm sid:844428202803264 initiator:iqn.1995-12.com.attotech:xtendsan:4h5380brse6 cid:1 ip:10.50.100.104 state:active hd:none dd:none sid:564052737720384 initiator:iqn.1995-12.com.attotech:xtendsan:4h5380brse6 cid:1 ip:10.50.100.200 state:active hd:none dd:none # |
Notice that there are stale sessions. It doesn’t seem to hurt anything, but 10.50.100.200 is an old session that is not active.