Much of this was taken from http://www.markround.com/archives/archives/archives/archives/archives/archives/44-Building-a-redundant-iSCSI-and-NFS-cluster-with-Debian-Part-1.html. It was written in 2009, so some of the things have changed. I am not building a redundant array at this time (though that is the plan for the future), so this simply covers building the iSCSI target. As per the document, we're using IET.
First, set up your underlying storage for the iSCSI target. I use LVM2 sitting on top of mdadm.
# create RAID-6 software RAID consisting of sdb, sdc, sdd, sde mdadm --create /dev/md1 --raid-devices=4 --spare-devices=0 --level=6 --run /dev/sd[bcde] # now, add it (and all others) to the mdadm configuration file cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf.save /usr/share/mdadm/mkconf --generate > /etc/mdadm/mdadm.conf # add LVM volume group on top of it (apt-get install lvm2 if you haven't already) vgcreate iscsi-pool /dev/md1 # create logical volume named 'test' of 10G to make sure things are working (will be slow as mdadm is syncing the disks) lvcreate -L 10G -n test iscsi-pool mke2fs -j /dev/iscsi-pool/test mount /dev/isci-pool/test /mnt cp /etc/passwd /mnt cat /mnt/passwd rm /mnt/passwd
# you can see the progress of the madm build as follows:
cat /proc/mdstat
Now, start setting up iSCSI. We'll use IET for this install, though there are many more listed in the markaround article
# install iscsitarget # this will automatically build the kernel module and install it also
apt-get install iscsitarget iscsitarget-dkms # edit /etc/default/iscsitarget to enable !!!
/etc/init.d/iscsitarget start # verify iscsi working
grep -i iscsi /var/log/messages
Jan 1 15:26:58 serenity kernel: [11767.027654] iSCSI Enterprise Target Software - version 1.4.20.2 Jan 1 15:26:58 serenity kernel: [11767.027719] iscsi_trgt: Registered io type fileio Jan 1 15:26:58 serenity kernel: [11767.027721] iscsi_trgt: Registered io type blockio Jan 1 15:26:58 serenity kernel: [11767.027723] iscsi_trgt: Registered io type nullio # look at the iet conf directory to see the files created
ls /etc/iet
# OUTPUT ietd.conf initiators.allow targets.allow
# build a target # see http://en.wikipedia.org/wiki/ISCSI#Addressing for naming # create new target, id=1 name=iqn.2009-02.com.example:test ietadm --op new --tid=1 --params Name=iqn.2009-02.com.example:test # add LUN ID 0 to target and assign to LVM volume as backing store. Set access as fileio ietadm --op new --tid=1 --lun=0 --params Type=fileio,Path=/dev/iscsi-pool/test # verify creation cat /proc/net/iet/volume tid:1 name:iqn.2009-02.com.example:test lun:0 state:0 iotype:fileio iomode:wt path:/dev/isci-pool/test # Add to /etc/iet/ietd.conf so it will be there on restart
echo 'Target iqn.2009-02.com.example:test' >> /etc/iet/ietd.conf echo 'Lun 0 Path=/dev/storage/test,Type=fileio' >> /etc/iet/ietd.conf echo 'Alias test' >> /etc/iet/ietd.conf # restart daemon and show that target re-appears /etc/init.d/iscsitarget restart cat /proc/net/iet/volume
Cheating
Ok, this is cheating because you don't really learn what is going on, but Webmin (http://www.webmin.com/) has a very nice web interface for creating iSCSI targets. You still have to know something, but this will help a lot.
Debian does not have an installer for it, either because of the security or because of the fact there is a commercial side to it (I don't remember), but they have a Debian .deb package (http://www.webmin.com/download/deb/webmin-current.deb) which will install just fine. I strongly suggest you ensure it is secure because you are opening up a very powerful piece of code (able to manipulate your system as root) to a fairly insecure UI.
Actually, you can add their repository also, which is great since you'll get updates faster and it will satisfy the dependencies. See http://www.webmin.com/deb.html for details.
References
http://www.markround.com/archives/archives/44-Building-a-redundant-iSCSI-and-NFS-cluster-with-Debian-Part-1.html
http://www.gossamer-threads.com/lists/linuxha/users/45280
http://www.open-iscsi.org/
iSCSI appliance distros
openmediavault http://openmediavault.org/
freenas
openfiler