First Prepare a LUN (Logical Unit Number):
# dd if=/dev/zero of=/opt/lun0.img bs=1M seek=10240 count=0
This will allocate a thin provisioned LUN which will be used as for the iSCSI target device.
After that 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
Then create a target device
# tgtadm --lld iscsi --mode target --op new --tid=1 \
--targetname iqn.2012-04.com.aossama:datastor01
Add the LUN to the target device
# tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 -b /opt/lun0.img
Finally allow all initiators
# tgtadm --lld iscsi --mode target --op bind --tid 1 -I ALL
Check that everything is configured correctly
# tgtadm --lld iscsi --op show --mode target
And that’s it, simple!!!
But that’s not all the story, performing more advanced tasks such as setting CHAP authentication on the target and setting digest are covered in Part 2.