The [http://stgt.berlios.de/ SCSI Target Framework (STGT)] was the standard before linux 2.6.38.

+

The [http://stgt.berlios.de/ SCSI Target Framework (STGT/TGT)] was the standard before linux 2.6.38.

The current standard is the [http://linux-iscsi.org/ LIO target].

The current standard is the [http://linux-iscsi.org/ LIO target].

The [http://iscsitarget.sourceforge.net/ iSCSI Enterprise Target (IET)] is an old implementation and [http://scst.sourceforge.net/ SCSI Target Subsystem (SCST)] is the successor of IET and was a possible candidate for kernel inclusion before the decision fell for LIO.

The [http://iscsitarget.sourceforge.net/ iSCSI Enterprise Target (IET)] is an old implementation and [http://scst.sourceforge.net/ SCSI Target Subsystem (SCST)] is the successor of IET and was a possible candidate for kernel inclusion before the decision fell for LIO.

Line 107:

Line 107:

* You can also use {{ic|man targetcli}} when you installed the ''free branch'' version {{AUR|targetcli-fb}}.

* You can also use {{ic|man targetcli}} when you installed the ''free branch'' version {{AUR|targetcli-fb}}.

−

== Setup with SCSI Target Framework (STGT) ==

+

== Setup with SCSI Target Framework (STGT/TGT) ==

You will need the Package {{AUR|tgt}} from [[AUR]].

You will need the Package {{AUR|tgt}} from [[AUR]].

Revision as of 15:23, 31 March 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Using targetcli

There is also the original targetcliAUR package available, but it is additionally dependent on lio-utils and epydoc.
The external manual is only available in the free branch.

The config shell creates most names and numbers for you automatically, but you can also provide your own settings.
At any point in the shell you can type help 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

# targetcli

In this shell you include a block device (here: /dev/disk/by-id/md-name-nas:iscsi) to use with

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

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

...> cd /iscsi/iscsi> create

Note: With appending an iqn of your choice to create 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

.../tpg1> cd luns.../tpg1/luns> create /backstores/block/md_block0

Then you need to create a portal, making a daemon listen for incoming connections:

.../luns/lun0> cd ../../portals.../portals> create

Targetcli will tell you the IP and port where LIO is listening for incoming connections (defaults to 0.0.0.0 (all)).
You will need at least the IP for the clients. The port should be the standard port 3260.

In order for a client/initiator to connect you need to include the iqn of the initiator in the target configuration:

...> cd ../../acls.../acls> create iqn.2005-03.org.open-iscsi:SERIAL

Instead of iqn.2005-03.org.open-iscsi:SERIAL you use the iqn of an initiator.
It can normally be found in /etc/iscsi/initiatorname.iscsi.
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 whether the access should be rw or ro. See help create at 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 the configuration in /etc/target/saveconfig.json.
You can now safely start and stop /etc/rc.d/target without losing your configuration.

Tip: You can give a filename as a parameter to saveconfig and also clear a configuration with clearconfig

Authentication

Authentication per CHAP is enabled per default for your targets.
You can either setup passwords or disable this authentication.

Disable Authentication

Navigate targetcli to your target (i.e. /iscsi/iqn.../tpg1) and

.../tpg1> set attribute authentication=0

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.

Set Credentials

Navigate to a certain acl of your target (i.e. /iscsi/iqn.../tpg1/acls/iqn.../) and

...> get auth

will show you the current authentication credentials.

...> set auth userid=foo
...> set auth password=bar

Would enable authentication with foo:bar.

Using (plain) LIO utils

You have to install lio-utilsAUR from AUR and the dependencies (python2).

Tips & Tricks

With targetstatus you can list the current open sessions. This script is included in the targetcli-fbAUR package, but can also be used together with lio-utils or the original targetcli. It needs rtslib or rtslib-fb.