Jump to Navigation

251 - iSCSI target in /etc/tgt/targets.conf

< Create the targets >

Targets can be created by adding an XML entry to the /etc/tgt/targets.conf file, using our favorite text editor.
The target attribute requires an iSCSI Qualified Name (IQN).

Format :


yyyy-mm represents the 4-digit year and 2-digit month the device was started (for example: 2011-07)

reversed.domain.name is the hosts domain name in reverse.

For example, server1.example.com,
in an IQN, becomes com.example.server1; and OptionalIdentifierText is any text string, without spaces, that helps the administrator
identify which device is which.


Add the following to the /etc/tgt/targets.conf file :

<target iqn.2012-07.com.mydomain.myserver:target1>
backing-store /dev/mapper/vg_myserver/mydata   #LUN1
backing-store /dev/mapper/vg_temp/mytemp        #LUN2
write-cache off

LUN 0 will appear as a device of type "controller". You can see.

# tgtadm --lld iscsi --op show --mode target

Ensure that the /etc/tgt/targets.conf file contains the default-driver iscsi line to set the driver type as iSCSI
(the driver uses iSCSI by default, but make sure that line is not commented out).

Now you need to restart the tgtd service to reload the configuration changes :

# service tgtd restart


Main menu 2

Story | by Dr. Radut