iSCSI Initiator and Target Setup on Ubuntu
This walkthrough describes the setup of the linux ISCSI initiator and target. All commands must be executed as root:
Setup of the iSCSI initiator
1. Take a look at already registered LUNs:
iscsiadm -m node2. Find LUNs at a given IP:
iscsiadm -m discovery -t sendtargets -p 134.34.165.145:32603. Connect and login (without authentification):
iscsiadm -m node -T iqn.2010-04.local-test:disk-1 -p 134.34.165.145:3260 --login4. See if session runs:
iscsiadm --mode session5. Format with a filesystem and mount it:
mkfs.ext3 /dev/sdc1
mount /dev/sdc1 /iscsi6. Work with the mounted disk
7. Unmount and clean up
umount /iscsi
iscsiadm --mode node --targetname iqn.2010-04.local-test:disk-1 --portal 134.34.165.145:3260 --logoutiSCSI Enterprise Target Setup
Setting up an iSCSI enterprise target under Ubuntu follows the following workflows (taken from here):
1. Install the packages:
aptitude install iscsitarget iscsitarget-source iscsitarget-dkms2. Enable the target:
pico /etc/default/iscsitarget
#Insert the following content
ISCSITARGET_ENABLE=true3. Create Sparseimage:
mkdir storage
dd if=/dev/zero of=/storage/lun1.img bs=1024k count=200004. Define iSCSI LUN
pico /etc/iet/ietd.conf
#Insert the following content
Target iqn.2012-04.kn.uni.disy:storage.lun1
Lun 0 Path=/storage/lun1.img,Type=fileio
Alias LUN15. Enable the iSCSI LUN
pico pico /etc/iet/initiators.allow
#Insert the following content
iqn.2012-04.kn.uni.disy:storage.lun1 134.34.165.1456. Start the target
/etc/init.d/iscsitarget start