iSCSI mini howto

Some things in life, like iSCSI, are simple!
iSCSI is a protocol that allows you to have SCSI over IP.

The iSCSI Target

The host containing the physical hardware is called the iSCSI target and is easy to setup on Linux using iscsitarget.
aptitude install iscsitarget
aptitude install iscsitarget-dkms (Debian 6)

After enabling it in /etc/default/iscsitarget you can use files, hd devices, partitions, lvm volumes or software raid mdadm devices as 'physical hardware disks'
root@debby6:/etc/iet# cat ietd.conf
Target iqn.2010-02.be.linux-training:storage.lun1
IncomingUser isuser hunter2
Lun 0 Path=/iscsi/lun1.img,Type=fileio
Alias LUN1

Where /iscsi/lun1.img is a zeroed file created with
dd if=/dev/zero of=/iscsi/lun1.img count= bs=

Add the device to the allowed list:
root@debby6:/etc/iet# cat initiators.allow

and start the server. You should see this:
root@debby6:/etc/iet# cat /proc/net/iet/session
tid:1 name:iqn.2010-02.be.linux-training:storage.lun1
The iSCSI Initiator

The host that connects to this target server is called the Initiator. Most Linux distros have this available as open-iscsi.
aptitude install open-iscsi

A discovery will show available devices on the target:
root@ubu1104:/etc/iscsi# iscsiadm -m discovery -t st -p debby6,1 iqn.2010-02.be.linux-training:storage.lun2

Configuration with chap user and password takes a couple of commands:
root@ubu1104:/etc/iscsi# iscsiadm -m node --targetname "iqn.2010-02.be.linux-training:storage.lun1" --portal "debby6:3260" --op=update --name node.session.auth.authmethod --value=CHAP
root@ubu1104:/etc/iscsi# iscsiadm -m node --targetname "iqn.2010-02.be.linux-training:storage.lun1" --portal "debby6:3260" --op=update --name node.session.auth.username --value=isuser
root@ubu1104:/etc/iscsi# iscsiadm -m node --targetname "iqn.2010-02.be.linux-training:storage.lun1" --portal "debby6:3260" --op=update --name node.session.auth.password --value=hunter2

That's it! Now (re)start the open-iscsi service and use fdisk to see your iSCSI device.

1 comment:

Anonymous said...

Above procedure works with ip address allowed:

cat /etc/iet/initiators.allow