Configure iSCSI Remote Storage on Linux: Target and Initiator Setup

iSCSI (Internet Small Computer Systems Interface) provides block-level storage over IP networks. It allows servers to access remote storage (on a storage server) as if it were a locally attached disk.

iSCSI Terminology

  • Target — the server that exports storage (storage provider)
  • Initiator — the client that connects to and uses the storage
  • LUN — Logical Unit Number — a chunk of storage exported by the target
  • IQN — iSCSI Qualified Name — unique identifier for targets and initiators

iSCSI Profile

Target package:    targetcli (RHEL 7), scsi-target-utils (RHEL 6)
Initiator package: iscsi-initiator-utils
Target port:       3260/TCP
Target config:     /etc/target/ (RHEL 7), /etc/tgt/targets.conf (RHEL 6)
Initiator config:  /etc/iscsi/initiatorname.iscsi

Configure iSCSI Target (Server)

# Install targetcli:
# yum install targetcli -y

# Start target service:
# systemctl start target
# systemctl enable target

# Open targetcli interactive shell:
# targetcli

/> backstores/block create mystore /dev/sdb     # use disk as backend
/> iscsi/ create iqn.2026-06.com.example:server  # create IQN
/> iscsi/iqn.2026-06.com.example:server/tpg1/luns create /backstores/block/mystore
/> iscsi/iqn.2026-06.com.example:server/tpg1/portals create 172.25.9.11 3260
/> iscsi/iqn.2026-06.com.example:server/tpg1/ set attribute authentication=0
/> iscsi/iqn.2026-06.com.example:server/tpg1/ set attribute demo_mode_write_protect=0
/> saveconfig
/> exit

# Open firewall:
# firewall-cmd --permanent --add-port=3260/tcp
# firewall-cmd --reload

Configure iSCSI Initiator (Client)

# Install:
# yum install iscsi-initiator-utils -y

# Set initiator IQN:
# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2026-06.com.example:client

# Start service:
# systemctl start iscsi iscsid
# systemctl enable iscsi iscsid

# Discover targets:
# iscsiadm -m discovery -t st -p 172.25.9.11   # discover from target IP

# Login to target:
# iscsiadm -m node -T iqn.2026-06.com.example:server -p 172.25.9.11 -l

# List active iSCSI sessions:
# iscsiadm -m session

# Logout:
# iscsiadm -m node -T iqn.2026-06.com.example:server -p 172.25.9.11 -u

Use the iSCSI Disk

# After login, a new disk appears (e.g., /dev/sdb):
# lsblk                               # find the new disk
# fdisk /dev/sdb                      # partition it
# mkfs.xfs /dev/sdb1                  # format
# mkdir /mnt/iscsi
# mount /dev/sdb1 /mnt/iscsi

# Permanent mount (/etc/fstab):
/dev/sdb1  /mnt/iscsi  xfs  _netdev  0  0
# _netdev = wait for network before mounting

Auto-login on Boot

# iscsiadm -m node -T iqn.2026-06.com.example:server -p 172.25.9.11 \
    --op update -n node.startup -v automatic