Configure iSCSI Target Linux

Need to install the software needed to do the things below ? So, go here

Add a iSCSI target

So, it's time to configure some target, and use it on other system.
To specify a block device to be available through iSCSI for other system. You have to edit a file, this one :

/etc/ietd.conf

If it don't exist, let's create it (as root user):

# touch /etc/ietd.conf

I will only add an entire block device, to be as easy as possible.
The simpliest content of the file may contains something like that :

Target iqn.2008-04.my-domain:hostname
Lun 1 Path=/dev/sdc

What's does all means ?
First of all, the thing in bold are the ones that needs to customized to your needs.
By instance, the strange name after target keyword is the name of your iSCSI target on the network, see wikipedia for more information about the strange name. This is the name that referred to your iSCSI device on the network.
The number after lun keyword is an internal identifier for iSCSI target on the local system running the iSCSI target. So, there should only be one on the systemn, so two iSCSI disk must have different lun number. Otherwise, you will get an error.
And finally, as you might guess, after :

Path=

you have to write there the block device that you want to export across the network through iSCSI protocol.

So, to be clear, let's take an example.
We want to export the device :

/dev/hdc

with LUN number :

3

and a name1 of :

my_iscsi_name

So, the configuration file ( /etc/ietd.conf ) have to look like to :

Target my_iscsi_name
Lun 3 Path=/dev/hdc

Now, check first if the iSCSI daemon is already running :

/etc/init.d/iscsitarget status

and if's not started, let's start it with :
# /etc/init.d/iscsitarget start

If all goes properly, you will get this output :

Starting iSCSI enterprise target service: succeeded.

That's it ! Others computer on your lan or across internet can now use your iSCSI device.

Go here to known how to use this new iSCSI device from other computer.

List the available target

If you want to see all the iSCSI target available for other host, you can first check your :

/etc/ietd.conf

file, and each line beginning with :

Target

will be a target that other system can reach. This method is not sure, as perhaps someone add an iSCSI device on command line without using the file :

/etc/ietd.conf

The best method to see which iSCSI device is available for other host, is to run this command :

# cat /proc/net/iet/session

An output will be something like that :

tid:2 name:iqn.2008-04.my_company.knt:katmai-disk-d
tid:1 name:iqn.2008-04.my_company.knt:katmai
        sid:281474980708864 initiator:iqn.1993-08.org.debian:01.aa231de29b62
                cid:0 ip:192.168.1.193 state:active hd:none dd:none

What does it means ?
Each line beginning with :

tid

is an iSCSI device. So, in this example, there is 2 iSCSI device :

  1. tid:2 name:iqn.2008-04.my_company.knt:katmai-disk-d
  2. tid:1 name:iqn.2008-04.my_company.knt:katmai

There is still 2 others lines with indentation below :

tid:1 name:iqn.2008-04.my_company.knt:katmai

it means that the corresponding iSCSI target, so this one :

tid:1 name:iqn.2008-04.my_company.knt:katmai

is used by someone.
So, as you might gues, the first iSCSI target :

tid:2 name:iqn.2008-04.my_company.knt:katmai-disk-d

isn't used by any other host on the network.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License