Linux iSCSI Target (TCM)

From Alpine Linux
Revision as of 10:28, 29 September 2012 by Larena (talk | contribs) (remove redundant title)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Since kernel 2.6.38 Linux has a new generic Target Core module, merged from LIO [[1]], and since 3.1 there is iSCSI support. This how-to quickly explains how to use it. Currently the userland utils are available only in Alpine edge/main repository (upcoming Alpine 2.5).

Install the utilities to configure Target Core:

 # apk add targetcli

In contrast with plain text files as usual, all configuration is done in ConfigFS via targetcli shell (you can use tab for command auto-completion and "ls" for inspecting current config):

 # targetcli
 Welcome to the targetcli shell::
 Copyright (c) 2011 by RisingTide Systems LLC.
 For help on commands, type 'help'.
 /> ls
 o- / ..................................................................... [...]
 o- backstores .......................................................... [...]
 | o- fileio ............................................... [0 Storage Object]
 | o- iblock ............................................... [0 Storage Object]
 | o- pscsi ................................................ [0 Storage Object]
 | o- rd_dr ................................................ [0 Storage Object]
 | o- rd_mcp ............................................... [0 Storage Object]
 o- ib_srpt ........................................................ [0 Target]
 o- iscsi .......................................................... [0 Target]
 o- loopback ....................................................... [0 Target]
 o- qla2xxx ........................................................ [0 Target]
 /> 

You can create a file to be exported as a target:

 /> cd backstores/fileio
 /backstores/fileio> create file_backstore file1 1M
 Generating a wwn serial.
 Not using buffered mode.
 Created fileio file_backstore.
 /backstores/fileio>

Or you can use a block device:

 /> cd backstores/blockio
 /backstores/blockio> create block0 /dev/sda1

You can use any block device, including RAID and LVM2. Now create an iSCSI Target and a Target Portal Group (tpg) (the iqn is automatically created. You can also specify one by hand):

 /> cd /iscsi
 /iscsi> create
 Created target iqn.2003-01.org.linux-iscsi.rtsnode1.x8664:sn.83a8cde7aca8.
 Selected TPG Tag 1.
 Successfully created TPG 1.

Now you have to tell Target Core to use the previously create backstore for the target now created:

 ../tpg1> cd luns
 ../tpg1/luns> create lun=0 storage_object=/backstores/blockio/block0
 Successfully created LUN 0.

Now create the iSCSI portal:

 ../tpg1/luns> cd ../portals
 ../tpg1/portals> create ip_address=192.168.1.10
 Using default IP port 3260
 Successfully created network portal 192.168.1.10:3260.

By default authentication is enabled. To disable it:

 ../tpg1> set attribute authentication=0
 Parameter authentication is now '0'.
 ../tpg1> set attribute generate_node_acls=1
 Parameter generate_node_acls is now '1'.

Finally save the configuration:

 /> saveconfig
 Existing file /etc/target/saveconfig.json backed up to saveconfig.json.backup
 Configuration saved to /etc/target/saveconfig.json