targets.conf is the main configuration file for the TGT iSCSI Target Framework (TGT daemon tgtd), used to define iSCSI targets, LUNs (Logical Unit Numbers), and various settings such as access controls, authentication, and backend storage. This file plays a central role in setting up and managing iSCSI targets for the system.
The configuration file typically resides at /etc/tgt/targets.conf and contains directives that describe the iSCSI targets, along with details of LUNs and ACLs (Access Control Lists). The format of the configuration file is hierarchical and human-readable.
Key Sections and Parameters in targets.conf:
Global Options: You can define global options for all targets here, such as defaults for authentication methods or other iSCSI target settings.
default-driveriscsi
This sets the default driver to iscsi.
Target Definitions: A target represents a storage device that clients (initiators) can access over the network. Each target is identified by a unique IQN (iSCSI Qualified Name).
iqn.2025-03.com.example:storage.target1: The unique IQN for this target.
backing-store: Specifies the storage resource used by the target, which can be a block device like /dev/sdb1, a file, or a partition.
initiator-address: Specifies which initiator (client) is allowed to access the target, based on its IP address.
incominguser: Sets the username and password for authentication from the initiator to the target.
outgoinguser: Specifies the username and password for authentication when the target communicates with the initiator (for bidirectional authentication).
write-cache: Option to disable or enable the write cache for this target.
LUN (Logical Unit Number) Assignments: LUNs are logical representations of physical or virtual storage devices. They allow initiators to access specific partitions or devices. You can assign multiple LUNs to a single target.
In this example, LUN 1 is mapped to the physical device /dev/sdb1. Multiple LUNs can be assigned to a single target, giving access to various storage volumes.
Access Control Lists (ACLs): ACLs are used to restrict access to specific initiators. You can specify allowed initiator names (IQNs) or initiator IP addresses.
incominguser: Defines the username and password (in clear text) that the initiator must provide to authenticate.
Optional Parameters:
write-cache: Controls whether write caching is enabled or disabled for the backing store.
data-sha256: For enabling data digest checksums to improve data integrity.
Example of a Full targets.conf Configuration File:
Key Notes:
IQN Format: iSCSI Qualified Names (IQNs) follow the format iqn.YYYY-MM.<domain>:name, where YYYY-MM is the date the domain name was registered.
Initiator and Target: The initiator-address and initiator-name options are important to control which clients can connect to specific iSCSI targets, providing a mechanism for both IP-based and IQN-based access control.
Conclusion:
The targets.conf file is essential for configuring the iSCSI targets managed by the TGT daemon. It provides a highly flexible way to define and manage iSCSI targets, LUNs, access control lists, and security settings (such as CHAP). Through this configuration, you can set up centralized, network-based storage systems and securely manage access for remote clients (initiators).