Setup Environment
I have one Ubuntu server for iSCSI target and one Windows Machine for Initiator
Target Server
vignesh@vignesh-server:~$ sudo su
root@vignesh-server:~$ apt-get update
root@vignesh-server:~$ apt-get install iscsitarget
Note : If you have changed the kernel version (Upgraded your Ubuntu ) you may hit FATAL: Module iscsi_trgt not found. if you hit this issue run apt-get install iscsitarget-dkms
Creating Virtual Disk
Create a new virtual disk of desired size,I am creating 5000M
root@vignesh-server:~$ mkdir /mnt/iscsi
root@vignesh-server:~$ dd if=/dev/zero of=/mnt/iscsi/scsivdisk.img bs=1M count=5000
Note
dd is the Unix command , reads from STDIN and STDOUT but these can be change using if (Input file)and of (Output file)
bs is the block size and count is number of blocks, default bs is 512
iSCSI Configuration
Enable iSCSI Target
The iSCSI target server is disabled by default, so we need to enable it in the configuration file
root@vignesh-server:~$ nano /etc/default/iscsitarget
set
ISCSITARGET_ENABLE=true
Share Virtual Disk as Logical unit
We have to make the configuration in iSCSI Enterprise Target configuration
root@vignesh-server:~$ nano /etc/iet/ietd.conf
Set
Target iqn.2014-09.com.asvignesh:share1 Lun 0 Path=/mnt/iscsi/scsivdisk.img,Type=fileio
We can add our own authentication rules IncomingUser <username> <password> Which is optional
Now the disk is shared with the whole network, you can make rules for sharing in /etc/iet/initiators.allow Which is optional
root@vignesh-server:~$ nano /etc/iet/initiators.allow
iqn.2014-09.com.asvignesh:share1 10.9.0.0/24
Start the service
Yes…. We are done… now we can start the service
root@vignesh-server:~$ /etc/init.d/iscsitarget start