Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary heading Template:Article summary wiki Template:Article summary end
With Wikipedia:iSCSI you can access storage over an IP-based network.
The exported storage entity is the target and the importing entity is the initiator.
There are different modules available to set up the target. The SCSI Target Framework (STGT) was the standard before linux 2.6.38. The current standard is the LIO target. The iSCSI Enterprise Target (IET) is an old implementation and SCSI Target Subsystem (SCST) is the successor of IET and was a possible candidate for kernel inclusion before the decision fell for LIO.
There are packages available for LIO, STGT and IET in the AUR (see below).
- 1 Setup with LIO
- 2 Setup with SCSI Target Framework (STGT)
- 3 Setup with iSCSI Enterprise Target (IET)
- 4 See also
Setup with LIO
LIO target is included in the kernel since 2.6.38. However, the iSCSI target fabric is included since linux 3.1.
The important kernel modules are target_core_mod and iscsi_target_mod, which should be in the kernel and loaded automatically.
For the userspace utilities you needAUR.
You start LIO target with
# /etc/rc.d/target start
This will load needed modules and optionally loads the previously saved iscsi target configuration.
# /etc/rc.d/target status
you can show some information about the running configuration.
You can use targetcli to create the whole configuration or you can alternively use the lio utils tcm_* and lio_* directly.
You have to install AUR and the dependencies.
The config shell creates most names and numbers for you automatically, but you can als provide your own settings.
At any point in the shell you can type
help in order to see what commands you can issue here.
After starting the target (see above) you enter the configuration shell with
Using iscsi fabric module.
In this shell you include a block device (here:
/dev/sdc) to use with
/> cd backstores/iblock
/backstores/iblock> create iblock0 /dev/sdc
You then create an iSCSI Qualified Name (iqn) and a target portal group (tpg) with
...> cd /iscsi
createyou can keep targetcli from automatically creating an iqn
In order to tell LIO that your block device should get used as backstore for the target you issue
.../tpg1> cd luns
.../tpg1/luns> create /backstores/iblock/iblock0
Then you need to create a portal, making a daemon listen for incoming connections:
.../luns/lun0> cd ../../portals
Targetcli will tell you the IP and port where LIO is listening for incoming connections. You will need at least the IP for the clients. The port should be the standard port 3260.
In another root shell you issue this command:
# lio_node --disableauth iqn.2003-01.org.linux-iscsi.HOSTNAME.ARCH:sn.SERIAL 1
iqn.2003-01.org.linux-iscsi.HOSTNAME.ARCH:sn.SERIAL you have to use the iqn that was created for (or by) you. The
1 stands for the 1st tpg, which is called
tpg1 in the example.
In order for a client/initiator to connect you still need to include the iqn of the initiator in the target configuration:
...> cd ../../acls
.../acls> create iqn.2005-03.org.open-iscsi:SERIAL
iqn.2005-03.org.open-iscsi:SERIAL you use the iqn of an initiator.
You have to do this for every initiator that needs to connect.
Targetcli will automatically map the created lun to the newly created acl.
help createat this point in the targetcli shell.
The last thing you have to do in targetcli when everything works is saving the configuration with:
...> cd /| /> saveconfig
The will fill the scripts in
You can now safely start and stop
/etc/rc.d/target without losing your configuration.
You might want to include
target in your rc.conf#Daemons.
setting static devices with udev
when we are using ISCSI devices we want it to keep a consistency in our devices name. the best way to achieve that is by using udev rules.
all we need to do is tell udev the device id and how to name it. to do that we will use scsi_id.
important note : This procedure implements LUN device persistence using udev. Only use this procedure for hosts which are not using multipath.
first we will set the scsi_id default behavior to ensure the returned UUIDs contains no spaces. The IET iSCSI target otherwise returns spaces in UUIDs, which can cause problems.
vi /etc/scsi_id.config options=--whitelisted --replace-whitespace
once the default behavior is configured we can link the command to the sbin directory
ls -n /lib/udev/scsi_id /sbin/scsi_id
and test the command on our iscsi device:
scsi_id --whitelisted --replace-whitespace --device=/dev/sdb 3600601607db11e0013ab5a8e371ce111
now lets create the udev rule to make sure the configuraion will stick at startup :
go to the rules directory :
now create a new file unique for iscsi
cat > 75-iscsi.rules # the iscsi device rules # this will create an iscsi device for each of the targets KERNEL=="sd*", SUBSYSTEM=="block", PROGRAM="/sbin/scsi_id --whitelisted --replace-whitespace /dev/$name", RESULT=="3600601607db11e0013ab5a8e371ce111", NAME="isda"
important note the RESULT value must be equal to the result you recieved from the scsi_id command.
now reboot your system and check that the devices have been created :
ls -l /dev/isda brw-rw---- 1 root disk 8, 18 May 25 23:35 /dev/isda
Using (plain) LIO utils
You have to install AUR and the dependencies (python2).AUR from
Setup with SCSI Target Framework (STGT)
You will need the Package AUR.AUR from
This is also linked on the official STGT website.
Setup with iSCSI Enterprise Target (IET)
You will need AUR.AUR and AUR from
Create the Target
Modify /etc/iet/ietd.conf accordingly
Hard Drive Target
Target iqn.2010-06.ServerName:desc Lun 0 Path=/dev/sdX,Type=blockio
File based Target
Use "dd" to create a file of the required size, this example is 10GB.
dd if=/dev/zero of=/root/os.img bs=1G count=10
Target iqn.2010-06.ServerName:desc Lun 0 Path=/root/os.img,Type=fileio
Start server services
rc.d start iscsi-target
Also you can "iscsi-target" to DAEMONS in /etc/rc.conf so that it starts up during boot.
- iSCSI Boot Booting Arch Linux with / on an iSCSI target.