Monday, April 23, 2012

Setup iSCSI Target with iscsi-scst 2.0

Environment: Ubuntu 11.04 for i386

1) Install Linux kernel with scst patches(See my post on how to compile scst patched Linux kernel)

$sudo dpkg -i linux-headers-3.0.22-scstcustom_3.0.22-scstcustom-10.00.Custom_i386.deb
$sudo dpkg -i linux-image-3.0.22-scstcustom_3.0.22-scstcustom-10.00.Custom_i386.deb
Edit /boot/grub/grub.cfg to enable new kernel and reboot the host

2) Build scst and iscsi-scst against the new kernel

$cd ~/scst
$sudo make scst scst_install iscsi-scst iscsi_install scstadmin scstadmin_install

See iscsi-scst/README and iscsi-scst/doc for detailed instructions for iscsi-scst compile and configuration introduction.

3) Setup iSCSI target with 2 LUNs (based on iscsi-scst)
$ su
Password:
# modprobe scst
# modprobe scst_vdisk
# echo "add_device disk1 filename=/home/hui/vdisk1; nv_cache=1" >/sys/kernel/scst_tgt/handlers/vdisk_fileio/mgmt
# echo "add_device disk2 filename=/home/hui/vdisk2; nv_cache=1" >/sys/kernel/scst_tgt/handlers/vdisk_fileio/mgmt
# modprobe iscsi_scst
# iscsi-scstd
# echo "add_target iqn.2006-10.net.vlnb:tgt" >/sys/kernel/scst_tgt/targets/iscsi/mgmt
# echo "add disk1 0" >/sys/kernel/scst_tgt/targets/iscsi/iqn.2006-10.net.vlnb:tgt/luns/mgmt
# echo "add disk2 1" >/sys/kernel/scst_tgt/targets/iscsi/iqn.2006-10.net.vlnb:tgt/luns/mgmt
# echo 1 >/sys/kernel/scst_tgt/targets/iscsi/iqn.2006-10.net.vlnb:tgt/enabled
# echo 1 >/sys/kernel/scst_tgt/targets/iscsi/enabled
4)Alternative way to setup iscsi target is to put the following content to /etc/scst.conf.
HANDLER vdisk_fileio {
        DEVICE disk01 {
                filename /home/hui/vdisk1
                nv_cache 1
        }
        DEVICE disk02 {
                filename /home/hui/vdisk2
                nv_cache 1
        }
}

TARGET_DRIVER iscsi {
        enabled 1

        TARGET iqn.2006-10.net.vlnb:tgt {
                LUN 0 disk01
                LUN 1 disk02

                enabled 1
        }
}
Then start scst service:
$sudo service scst start

5) Setup iSCSI initiator to discover the new devices(assume open-iscsi installed)

$sudo iscsiadm -m discovery -t st -p192.168.1.1
$sudo iscsiadm -m node -T iqn.2006-10.net.vlnb:tgt -p 192.168.1.1 -l

No comments:

Post a Comment