<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nirsof</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nirsof"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Nirsof"/>
	<updated>2026-04-28T06:07:33Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Linux_iSCSI_Target_(TCM)&amp;diff=18179</id>
		<title>Linux iSCSI Target (TCM)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Linux_iSCSI_Target_(TCM)&amp;diff=18179"/>
		<updated>2020-11-11T17:37:45Z</updated>

		<summary type="html">&lt;p&gt;Nirsof: Starting targetcli fail with &amp;quot;g-io-error-quark: Could not connect: No such file or directory&amp;quot; if dbus service is not running. Start dbus before targetcli, and change service order for consistency.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since kernel 2.6.38 Linux has a new generic Target Core module, merged from LIO [[http://linux-iscsi.org/wiki/Main_Page]], and since 3.1 there is iSCSI support. This how-to quickly explains how to use it.&lt;br /&gt;
&lt;br /&gt;
Install the utilities to configure Target Core:&lt;br /&gt;
&lt;br /&gt;
  # apk add targetcli&lt;br /&gt;
  # rc-update add dbus&lt;br /&gt;
  # rc-update add targetcli&lt;br /&gt;
  # service dbus start&lt;br /&gt;
  # service targetcli start&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;ls&amp;quot; for inspecting current config):&lt;br /&gt;
&lt;br /&gt;
  # targetcli&lt;br /&gt;
  Welcome to the targetcli shell::&lt;br /&gt;
  Copyright (c) 2011 by RisingTide Systems LLC.&lt;br /&gt;
&lt;br /&gt;
  For help on commands, type &#039;help&#039;.&lt;br /&gt;
&lt;br /&gt;
  /&amp;gt; ls&lt;br /&gt;
  o- / ..................................................................... [...]&lt;br /&gt;
  o- backstores .......................................................... [...]&lt;br /&gt;
  | o- fileio ............................................... [0 Storage Object]&lt;br /&gt;
  | o- iblock ............................................... [0 Storage Object]&lt;br /&gt;
  | o- pscsi ................................................ [0 Storage Object]&lt;br /&gt;
  | o- rd_dr ................................................ [0 Storage Object]&lt;br /&gt;
  | o- rd_mcp ............................................... [0 Storage Object]&lt;br /&gt;
  o- ib_srpt ........................................................ [0 Target]&lt;br /&gt;
  o- iscsi .......................................................... [0 Target]&lt;br /&gt;
  o- loopback ....................................................... [0 Target]&lt;br /&gt;
  o- qla2xxx ........................................................ [0 Target]&lt;br /&gt;
  /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
You can create a file to be exported as a target:&lt;br /&gt;
&lt;br /&gt;
  /&amp;gt; cd backstores/fileio&lt;br /&gt;
  /backstores/fileio&amp;gt; create file_backstore file1 1M&lt;br /&gt;
  Generating a wwn serial.&lt;br /&gt;
  Not using buffered mode.&lt;br /&gt;
  Created fileio file_backstore.&lt;br /&gt;
  /backstores/fileio&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or you can use a block device:&lt;br /&gt;
&lt;br /&gt;
  /&amp;gt; cd backstores/blockio&lt;br /&gt;
  /backstores/blockio&amp;gt; create block0 /dev/sda1&lt;br /&gt;
&lt;br /&gt;
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):&lt;br /&gt;
&lt;br /&gt;
  /&amp;gt; cd /iscsi&lt;br /&gt;
  /iscsi&amp;gt; create&lt;br /&gt;
  Created target iqn.2003-01.org.linux-iscsi.rtsnode1.x8664:sn.83a8cde7aca8.&lt;br /&gt;
  Selected TPG Tag 1.&lt;br /&gt;
  Successfully created TPG 1.&lt;br /&gt;
&lt;br /&gt;
Now you have to tell Target Core to use the previously create backstore for the target now created:&lt;br /&gt;
&lt;br /&gt;
  /iscsi&amp;gt; cd iqn.2003-01.org.linux-iscsi.rtsnode1.x8664:sn.83a8cde7aca8/tpg1/luns&lt;br /&gt;
  ../tpg1/luns&amp;gt; create lun=0 storage_object=/backstores/blockio/block0&lt;br /&gt;
  Successfully created LUN 0.&lt;br /&gt;
&lt;br /&gt;
Now create the iSCSI portal:&lt;br /&gt;
&lt;br /&gt;
  ../tpg1/luns&amp;gt; cd ../portals&lt;br /&gt;
  ../tpg1/portals&amp;gt; create ip_address=192.168.1.10&lt;br /&gt;
  Using default IP port 3260&lt;br /&gt;
  Successfully created network portal 192.168.1.10:3260.&lt;br /&gt;
&lt;br /&gt;
By default authentication is enabled. To disable it:&lt;br /&gt;
&lt;br /&gt;
  ../tpg1&amp;gt; set attribute authentication=0&lt;br /&gt;
  Parameter authentication is now &#039;0&#039;.&lt;br /&gt;
  ../tpg1&amp;gt; set attribute generate_node_acls=1&lt;br /&gt;
  Parameter generate_node_acls is now &#039;1&#039;.&lt;br /&gt;
&lt;br /&gt;
Finally save the configuration:&lt;br /&gt;
&lt;br /&gt;
  /&amp;gt; saveconfig&lt;br /&gt;
  Existing file /etc/target/saveconfig.json backed up to saveconfig.json.backup&lt;br /&gt;
  Configuration saved to /etc/target/saveconfig.json&lt;br /&gt;
&lt;br /&gt;
For real use, you should always track changes to the saveconfig file and make sure &lt;br /&gt;
(there&#039;s a flag for it) to not save config if you are in an error situation. By default, &lt;br /&gt;
targetcli creates a config backup if you exit, meaning you might lose the working&lt;br /&gt;
config at the time. So better to be prepared.&lt;br /&gt;
Errors don&#039;t simply appear, but i.e. if you&#039;re missing a HBA on boot, these settings&lt;br /&gt;
will not be loaded and thus not be in the configuration upon save.&lt;br /&gt;
&lt;br /&gt;
[[Category:Storage]]&lt;/div&gt;</summary>
		<author><name>Nirsof</name></author>
	</entry>
</feed>