iSCSI (server) on CentOS6/RHEL6

 

Add disk to system so it appears fdisk -l ( for example /dev/sdb )

Install scsi-target-utils.x86_64 package, enable the service and start it

# yum -y install scsi-target-utils.x86_64
# chkconfig tgtd on
# service tgtd start

 

To be able to extend the LUN later on I use LVM

# pvcreate /dev/sdb
# vgcreate vg_datastore_01 /dev/sdb
# lvcreate -n lun1 -L 100G vg_datastore_01
# lvcreate -n lun2 -L 100G vg_datastore_01

 

Then create a target device ( where Target ID=1 )

# tgtadm –lld iscsi –mode target –op new –tid=1 –targetname iqn.2013-10.hemi-it:datastore01

 

Add the LUN to the target device

# tgtadm –lld iscsi –mode logicalunit –op new –tid 1 –lun 1 -b /dev/vg_datastore_01/lun1
# tgtadm –lld iscsi –mode logicalunit –op new –tid 1 –lun 2 -b /dev/vg_datastore_01/lun2

 

Finally allow all initiators

# tgtadm –lld iscsi –mode target –op bind –tid 1 -I ALL
or
# tgtadm –lld iscsi –mode target –op bind –tid 1 -I <IP Address of the system to use the iscsi devices>

 

Check that everything is configured correctly

# tgtadm –lld iscsi –op show –mode target

 

NOTE: Don’t forget to add the above info to [ /etc/tgt/targets.conf ]. Otherwise after a reboot it won’t work anymore

Add to [ /etc/tgt/targets.conf ]

<target iqn.2013-10.hemi-it:datastore01>
# provided devicce as a iSCSI target
backing-store /dev/vg_datastore_01/lun1
backing-store /dev/vg_datastore_01/lun2
# iSCSI Initiator’s IP address you allow to connect
initiator-address <IP Address of the system to use the iscsi devices>
</target>