Setting up a Target

Using the Linux iSCSI Target Implemention from Ardis Technologies we can create iSCSI targets on any Linux system which can be accessed from the iSCSI initiator we'll set up in the next section. A system that will make targets available only needs some partition to be available for export, and it does not need to be a SCSI disk.

The following are the steps to setup an iSCSI target.

Procedure 1. Setting up an ISCSI Target

  1. Download the iSCSI Target code from:


    I had problems with the 20040211 release, when loading the modules I'd get unresolved symbols. Using the January released worked fine.

  2. Download and configure (make menuconfig) a Linux 2.4.22 kernel. Patch the kernel with the diff in the target code (ie: kernel.2.4.22.diff).

    [benr@nexus linux-2.4.22]$ patch -p0 < 
    patching file include/linux/mm.h
    patching file include/linux/pagemap.h
    patching file kernel/ksyms.c
    patching file mm/filemap.c
    [benr@nexus linux-2.4.22]$
  3. There are no iSCSI options you need to select except to have the normal SCSI driver built. Just build and install your kernel in the usual way. Then boot it.

  4. Next, build the target module and tools source. You'll need to define the environmental variable KERNELSRC to point to the location of the kernel tree you patched and installed.

    [benr@nexus linux-iscsi-target-20040116]$ make        
    set $KERNELSRC!
    [benr@nexus linux-iscsi-target-20040116]$ export KERNELSRC=../linux-2.4.22
    [benr@nexus linux-iscsi-target-20040116]$ make
     ( ... Removed for clarity ... )
    [benr@nexus linux-iscsi-target-20040116]$ make install
     ( ... Removed for clarity ... )

    This will install the iSCSI target module (iscsi_trgt_mod.o) into /lib/modules and the target daemon (iscsi_trgtd) into /usr/sbin.

  5. Copy the iscsid.config file to /etc, and edit it to meet your needs.

    [benr@nexus /etc]$ cat iscsid.config
    ## iSCSId Target Configuration File
    User benr
            # Lun definition
            # (right now only block devices are possible)
            Lun 0 /dev/sdb
            # Alias name for this target
            Alias Test
            # Lun definition
            # (right now only block devices are possible)
            Lun 0 /dev/sdc
            # Alias name for this target
            Alias NTFS
  6. Copy the iscsid.rc to /etc/init.d/iscsid and make it executable.

  7. Now, you should be able to start the iSCSI Targets.

    [root@nexus /root]# /etc/init.d/iscsid start
    Starting iSCSI target.
    [root@nexus /root]#

As defined in the above procedure, according to my iscsid.conf, I'm offering 2 iSCSI targets. I can use these target names later when I connect to them with an initiator.

Keep an eye on the syslog when you start the iSCSI Target Daemon (tail -f /var/log/messages) to watch for startup messages and any warnings.