ISCSI Target

From ArchWiki
Revision as of 11:34, 10 October 2011 by JonnyJD (Talk | contribs) (Setup with LIO: + upstream doc links)

Jump to: navigation, search
Summary help replacing me
How to set up an iSCSI Target using different tools.
Series
iSCSI Target
iSCSI Initiator
Related
iSCSI Boot

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.


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. You can test the 3.1rc with Template:Package AUR when you add Template:Codeline to the kernel config.

The important kernel modules are target_core_mod and iscsi_target_mod, which should be in the kernel and loaded automatically.

You start LIO target with Template:Cli This will load needed modules and optionally loads the previously saved iscsi target configuration.

With Template:Cli 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.


Using targetcli

You have to install Template:Package AUR from 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 Template:Codeline in order to see what commands you can issue here.

Tip: You can use tab-completion in this shell


After starting the target (see above) you enter the configuration shell with Template:Command In this shell you include a block device (here: Template:Filename) to use with Template:Cli

Note: You can use any block device, also raid and lvm devices. You can also use files when you go to fileio instead of iblock.

You then create an iSCSI Qualified Name (iqn) and a target portal group (tpg) with Template:Cli

Note: With appending an iqn of your choice to Template:Codeline you 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 Template:Cli

Then you need to create a portal, making a daemon listen for incoming connections: Template:Cli 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: Template:Command Instead of Template:Codeline you have to use the iqn that was created for (or by) you. The Template:Codeline stands for the 1st tpg, which is called Template:Codeline in the example.

Warning: With this setting everybody that knows the iqn of one of your clients (initiators) can access the target. This is for testing or home purposes only.

In order for a client/initiator to connect you still need to include the iqn of the initiator in the target configuration: Template:Cli Instead of Template:Codeline 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.

Note: You can change the mapped luns and if the access should be rw or ro. See Template:Codeline at this point in the targetcli shell.

The last thing you have to do in targetcli when everything works is saving the configuration with Template:Cli You can now safely start and stop Template:Filename without losing your configuration.

You might want to include Template:Codeline in your rc.conf#Daemons.


Using (plain) LIO utils

You have to install Template:Package AUR from AUR and the dependencies.


Upstream Documentation

Setup with iSCSI Enterprise Target

You will need Template:Package AUR and Template:Package AUR from AUR, make sure you've got the dependencies.

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.


See also

  • iSCSI Boot Booting Arch Linux with / on an iSCSI target.