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 OutgoingUser 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 iqn.2010-02.be.linux-training:storage.lun1
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.lun1The 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 192.168.1.31:3260,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:
Above procedure works with ip address allowed:
cat /etc/iet/initiators.allow
iqn.2010-02.be.linux-training:storage.lun1 192.168.1.101
iqn.2010-02.be.linux-training:storage.lun2 192.168.1.102
iqn.2010-02.be.linux-training:storage.lun3 192.168.1.101
Post a Comment