Introduction
This page summarises configuring iSCSI on Debian 6 and 7. Thanks to HowtoForge's excellent "Using iSCSI On Debian Squeeze (Initiator And Target)" from which most of the information was learned.
Overview
iSCSI allows a server to provide a virtual block device over a network to a client. The virtual block device can then be treated like a real block device – for example it can be partitioned and file systems created in the partitions.
In iSCSI terminology the server is a "target" and the client is an "initiator"
Links
HowtoForge's "Using iSCSI On Debian Squeeze (Initiator And Target)": http://www.howtoforge.com/using-iscsi-on-debian-squeeze-initiator-and-target
Open-iSCSI: http://www.open-iscsi.org/ including a README: http://www.open-iscsi.org/docs/README
iSCSI Enterprise Target: http://iscsitarget.sourceforge.net/
Setting up the target (server)
Installation
aptitude -y install iscsitarget iscsitarget-dkms
Configuration
Optionally make a backup of the configuration files that will be changed: /etc/default/iscsitarget and /etc/iet/ietd.conf.
sed -i 's/ISCSITARGET_ENABLE=false/ISCSITARGET_ENABLE=true' /etc/default/iscsitarget
The next step sets up to serve a single LVM volume, /dev/vg0/lv0. Values that need to be changed are red.
user=someone
password=secret
local_device=/dev/vg0/lv0
oIFS=$IFS; array=($(hostname --long)); IFS=$oIFS
for ((i=${#array[*]};i>0;i--)); do backwards_fqdn+=.${array[i-1]}; done
( echo "Target iqn.$(date +%Y-%m)$backwards_fqdn:storage.lun0"
echo " IncomingUser $user $password"
echo " OutgoingUser"
echo " Lun 0 Path=$local_device,Type=fileio"
echo " Alias LUN0"
) > /etc/iet/ietd.conf
Further devices can be added by editing /etc/iet/ietd.conf, replicating and modifying the first stanza.