Installation guide
iSCSI-based storage pools
225
c. Configure SELinux file contexts
Configure the correct SELinux context for the new image and directory.
# restorecon -R /var/lib/tgtd
The new file-based image, virtimage2.img, is ready to use for iSCSI.
5. Create targets
Targets can be created by adding a XML entry to the /etc/tgt/targets.conf file. The
target attribute requires an iSCSI Qualified Name (IQN). The IQN is in the format:
iqn.yyyy-mm.reversed domain name:optional identifier text
Where:
• yyyy-mm represents the year and month the device was started (for example: 2010-05);
• reversed domain name is the hosts domain name in reverse (for example
server1.example.com in an IQN would be com.example.server1); and
• optional identifier text is any text string, without spaces, that assists the administrator
in identifying devices or hardware.
This example creates iSCSI targets for the two types of images created in the optional steps on
server1.example.com with an optional identifier trial. Add the following to the /etc/tgt/
targets.conf file.
<target iqn.2010-05.com.example.server1:trial>
backing-store /dev/virtstore/virtimage1 #LUN 1
backing-store /var/lib/tgtd/virtualization/virtimage2.img #LUN 2
write-cache off
</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.
Important
This example creates a globally accessible target without access control. Refer to the scsi-
target-utils for information on implementing secure access.
6. Restart the tgtd service
Restart the tgtd service to reload the configuration changes.
# service tgtd restart
7. iptables configuration
Open port 3260 for iSCSI access with iptables.
# iptables -I INPUT -p tcp -m tcp --dport 3260 -j ACCEPT
# service iptables save