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

Planning

Information required:

Setting up the target (server)

Installation

aptitude -y install iscsitarget iscsitarget-dkms

Configuration

Optionally backup 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.  Values that are arbitrary strings (so could be changed) are in blue.

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.

Setting up the initiator (client)

Installation

aptitude -y install open-iscsi

Configuration

Optionally backup the configuration file that will be changed: /etc/iscsi/iscsid.conf.

sed -i 's/node.startup = manual/node.startup = automatic/' /etc/iscsi/iscsid.conf

In the next step we use the iSCSI daemon to generate the configuration.

/etc/init.d/open-iscsi restart

iscsiadm -m discovery -t st -p 192.168.10.27

Issue investigation