iSCSI lets one Linux host hand a block device to another over TCP: the server exports a LUN through the kernel’s LIO target, the client attaches it with open-iscsi, and a new /dev/sdX appears as if someone had plugged in a disk. That last part is exactly where people get hurt. What crosses the network is blocks, not files — the initiator’s kernel owns the filesystem, and if two initiators log into the same LUN and both mount it with ext4, they will corrupt it within minutes, because neither one knows the other is writing. Treat a LUN like a physical disk with one owner. This guide builds the target with targetcli, connects one initiator, makes the mount come back after a reboot, and closes the default that would otherwise let any host on the subnet log in.
What you’ll accomplish
- Export an LVM logical volume as an iSCSI LUN from a Linux host using the in-kernel LIO target.
- Attach that LUN from a second host with
open-iscsiand format it with ext4. - Restrict the LUN to one initiator IQN with an ACL, and require a CHAP secret on top of that.
- Get the mount back automatically after the initiator reboots, without hanging boot.
- Know how to tell an authorization failure apart from a network failure when login breaks.
Prerequisites
- Target host:
targetcli-fbon Debian and Ubuntu (apt install targetcli-fb),targetclion the RHEL family (dnf install targetcli). Both drive the same in-kernel LIO subsystem; the package names differ only by history. - Initiator host:
open-iscsion Debian and Ubuntu (apt install open-iscsi),iscsi-initiator-utilson the RHEL family (dnf install iscsi-initiator-utils). - Something to export. An LVM logical volume is the usual choice because you can grow it later. A whole disk or a partition works too. Do not export a file on a filesystem unless you have a reason to — the
fileiobackstore is convenient for lab work and slower and less predictable under load thanblock. - TCP 3260 reachable from initiator to target. A dedicated storage network or VLAN is strongly preferable: iSCSI traffic is unencrypted, CHAP protects the login and nothing after it, and storage latency hates competing with application traffic. At minimum, write a firewall rule that allows 3260 from the initiator address only.
- Root on both hosts.
targetcliandiscsiadmboth need it. - One honest note on implementations: LIO (
target_core_mod, driven bytargetcli) has been the kernel’s iSCSI target since Linux 2.6.38 and is what you want. The older userspacetgt(tgtadm) still exists and still works, but its configuration model is unrelated to everything below, so do not mix guides.
Official sources worth keeping open: open-iscsi and targetcli-fb.
How it works
Every endpoint in iSCSI is named by an IQN — an iSCSI Qualified Name, in the form iqn.YYYY-MM.reversed.domain:label, for example iqn.2026-07.com.example:disk1. The date is the month your organization owned that domain; nothing validates it, but the format matters because the target matches initiators on this string exactly.
On the target, four objects stack up. A backstore points at real storage (block for a device, fileio for a file). A target is created under /iscsi and gets an IQN. Inside it lives a target portal group (TPG 1 by default), which holds the portals — the IP:port pairs it listens on, 0.0.0.0:3260 unless you narrow it — plus a list of LUNs mapping backstores into the group, and a list of ACLs.
The ACL is the part that actually protects you. An ACL is keyed on the initiator’s IQN and says: this initiator may see these LUNs. If demo mode is left on, the TPG generates ACLs for whoever asks and every host on the subnet gets your disk. CHAP is negotiated during the login phase and can be set per-ACL, so each initiator gets its own userid and secret.
Two operations are easy to confuse. Discovery (sendtargets) asks a portal “what targets do you have?” and, by default, needs no ACL — it is a directory lookup. Login opens a session against a specific target, and that is where the ACL and CHAP are enforced. Discovery working tells you nothing about whether login will.
Step-by-step
Throughout, <target-ip> is the target’s address on the storage network, and the two IQNs are iqn.2026-07.com.example:disk1 (target) and iqn.2026-07.com.example:app01 (initiator). Substitute your own domain.
1. Install and start the target service.
apt install targetcli-fb
systemctl enable --now rtslib-fb-targetctl.service
On the RHEL family that is dnf install targetcli and systemctl enable --now target.service. The service does not serve iSCSI itself — the kernel does. Its only job is restoring your saved configuration at boot, which is why forgetting to enable it means an empty target after a reboot.
2. Create the backstore. Assume the volume already exists as /dev/vg_data/lv_iscsi. Enter the shell and create a block backstore:
targetcli
/> /backstores/block create name=data0 dev=/dev/vg_data/lv_iscsi
Created block storage object data0 using /dev/vg_data/lv_iscsi.
3. Create the target. One command, and LIO fills in the TPG and portal for you:
/> /iscsi create iqn.2026-07.com.example:disk1
Created target iqn.2026-07.com.example:disk1.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
4. Confirm the portal. Point the shell at the TPG and list it:
/> cd /iscsi/iqn.2026-07.com.example:disk1/tpg1
/iscsi/iqn.20...:disk1/tpg1> ls
o- tpg1 .................................. [no-gen-acls, no-auth]
o- acls ......................................... [ACLs: 0]
o- luns ......................................... [LUNs: 0]
o- portals ................................... [Portals: 1]
o- 0.0.0.0:3260 ..................................... [OK]
If the target sits on a host with several interfaces and you want it bound to the storage NIC only, delete the wildcard portal and create a specific one: portals/ delete 0.0.0.0 3260 then portals/ create <storage-ip> 3260.
5. Map the LUN.
/iscsi/iqn.20...:disk1/tpg1> luns/ create /backstores/block/data0
Created LUN 0.
6. Create the ACL for the initiator. This is the IQN you will put in /etc/iscsi/initiatorname.iscsi on the client in step 9 — decide it now and keep the two identical:
/iscsi/iqn.20...:disk1/tpg1> acls/ create iqn.2026-07.com.example:app01
Created Node ACL for iqn.2026-07.com.example:app01
Created mapped LUN 0.
The second line matters: creating an ACL after the LUN exists maps the LUN into it automatically. Create the ACL first and you get an ACL with no LUNs, a successful login, and no disk.
7. Set CHAP on the ACL and turn off demo mode.
/iscsi/iqn.20...:disk1/tpg1> acls/iqn.2026-07.com.example:app01 set auth userid=app01
/iscsi/iqn.20...:disk1/tpg1> acls/iqn.2026-07.com.example:app01 set auth password=SharedSecret4iSCSI
/iscsi/iqn.20...:disk1/tpg1> set attribute authentication=1
/iscsi/iqn.20...:disk1/tpg1> set attribute generate_node_acls=0
/iscsi/iqn.20...:disk1/tpg1> set attribute demo_mode_write_protect=0
Parameter userid is now 'app01'.
Parameter password is now 'SharedSecret4iSCSI'.
Parameter authentication is now '1'.
Parameter generate_node_acls is now '0'.
Parameter demo_mode_write_protect is now '0'.
The CHAP secret must be 12 to 16 characters. Shorter and the initiator refuses to send it; the log line you get back looks like an authentication failure rather than a length problem, which wastes a good half hour.
8. Save and open the port. saveconfig persists the whole tree; exit does it too, but be explicit:
/iscsi/iqn.20...:disk1/tpg1> saveconfig
/iscsi/iqn.20...:disk1/tpg1> exit
Configuration saved to /etc/rtslib-fb-target/saveconfig.json
On the RHEL family the path is /etc/target/saveconfig.json. Then allow the port from the initiator only:
ufw allow from 10.20.0.21 to any port 3260 proto tcp
# RHEL family:
# firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.20.0.21/32 port port=3260 protocol=tcp accept'
# firewall-cmd --reload
9. Set the initiator’s IQN. On the client, edit /etc/iscsi/initiatorname.iscsi so it holds exactly the string in your ACL:
echo 'InitiatorName=iqn.2026-07.com.example:app01' > /etc/iscsi/initiatorname.iscsi
10. Configure CHAP on the initiator. In /etc/iscsi/iscsid.conf, uncomment and set the session auth block:
node.session.auth.authmethod = CHAP
node.session.auth.username = app01
node.session.auth.password = SharedSecret4iSCSI
Then restart the daemon so both files are re-read:
systemctl restart iscsid
systemctl is-active iscsid
active
Note that iscsid.conf supplies defaults for new node records. Records you created earlier keep their own copy of these settings in /etc/iscsi/nodes/, which is why editing the config file appears to do nothing for a target you already discovered.
11. Discover the target.
iscsiadm -m discovery -t sendtargets -p <target-ip>
10.20.0.10:3260,1 iqn.2026-07.com.example:disk1
12. Log in.
iscsiadm -m node -T iqn.2026-07.com.example:disk1 -p <target-ip> --login
Logging in to [iface: default, target: iqn.2026-07.com.example:disk1, portal: 10.20.0.10,3260]
Login to [iface: default, target: iqn.2026-07.com.example:disk1, portal: 10.20.0.10,3260] successful.
13. Find the new device.
lsblk --scsi
lsblk /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sdb 8:16 0 100G 0 disk
iscsiadm -m session -P 3 prints the same mapping in more detail, including the Attached scsi disk sdb State: running line — useful when several LUNs land at once and lsblk alone leaves you guessing which is which.
14. Make a filesystem. You can partition it first, but for a single-purpose LUN there is no need:
mkfs.ext4 -L iscsidata /dev/sdb
mkdir -p /mnt/data
Creating filesystem with 26214400 4k blocks and 6553600 inodes
Filesystem UUID: 3f9a1c7e-8b42-4d16-9e05-71c2a4d8fb33
Writing superblocks and filesystem accounting information: done
15. Add the fstab entry with _netdev. Grab the UUID and use it — /dev/sdb is not stable across reboots:
blkid /dev/sdb
/dev/sdb: LABEL="iscsidata" UUID="3f9a1c7e-8b42-4d16-9e05-71c2a4d8fb33" TYPE="ext4"
Then append to /etc/fstab:
UUID=3f9a1c7e-8b42-4d16-9e05-71c2a4d8fb33 /mnt/data ext4 _netdev,noatime 0 2
_netdev tells systemd this mount needs the network up first. Without it, boot tries to mount a device that does not exist yet, and you get a very long timeout followed by an emergency shell.
16. Make the session come back at boot.
iscsiadm -m node -T iqn.2026-07.com.example:disk1 -p <target-ip> -o update -n node.startup -v automatic
systemctl enable iscsid open-iscsi
mount -a
findmnt /mnt/data
TARGET SOURCE FSTYPE OPTIONS
/mnt/data /dev/sdb ext4 rw,noatime,_netdev
On the RHEL family the units are iscsid.service and iscsi.service rather than open-iscsi.service.
Validate it works
Reboot the initiator. That is the only test that counts, and it is the one people skip:
reboot
# after it comes back
iscsiadm -m session
findmnt /mnt/data
tcp: [1] 10.20.0.10:3260,1 iqn.2026-07.com.example:disk1 (non-flash)
TARGET SOURCE FSTYPE OPTIONS
/mnt/data /dev/sdb ext4 rw,noatime,_netdev
Then check that you are getting real block throughput rather than page cache. oflag=direct bypasses the cache on write, iflag=direct on read:
dd if=/dev/zero of=/mnt/data/ddtest bs=1M count=2048 oflag=direct
dd if=/mnt/data/ddtest of=/dev/null bs=1M iflag=direct
rm /mnt/data/ddtest
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 19.4 s, 111 MB/s
111 MB/s is a gigabit link running at line rate. If you see that number on a 10G network, the bottleneck is not the disks.
Finally, prove the ACL works by confirming an unauthorized host is turned away. From a third host with no ACL entry, discovery still succeeds and login does not:
iscsiadm -m node -T iqn.2026-07.com.example:disk1 -p <target-ip> --login
iscsiadm: Could not login to [iface: default, target: iqn.2026-07.com.example:disk1, portal: 10.20.0.10,3260].
iscsiadm: initiator reported error (24 - iSCSI login failed due to authorization failure)
That is the outcome you want. Check journalctl -u rtslib-fb-targetctl and dmesg on the target for the rejection line naming the IQN it refused.
Troubleshooting
Discovery works, login fails with error 24. Authorization failure means the target saw you and said no. In order of likelihood: the initiator’s InitiatorName does not match the ACL string byte for byte (a trailing space or a typo in the date field is enough); the CHAP userid or secret differs between the ACL and iscsid.conf; the secret is under 12 characters; or you edited iscsid.conf after the node record already existed, so the old credentials are still in /etc/iscsi/nodes/. Compare iscsiadm -m node -T <target-iqn> -o show | grep auth against what you set on the target — that shows the values actually in use, not the defaults you meant to apply.
No portal reachable at all. iscsiadm -m discovery hanging or returning “connection refused” is a network or service problem, not an auth problem. Confirm the target service is enabled and the tree is populated (targetcli ls should not be empty after a reboot), confirm something is listening with ss -lntp | grep 3260 on the target, and check the firewall. If you narrowed the portal to a specific IP, make sure it is the address the initiator is actually routing to. Our notes on reading socket state with ss cover telling “nothing is listening” apart from “the SYN never arrived”.
The device appears, then boot breaks after the next reboot. Almost always a missing _netdev in the fstab line. systemd orders the mount before the network, the device is not there, and you sit through a 90-second timeout per attempt before landing in an emergency shell. Add _netdev, and confirm node.startup is automatic rather than manual so the session is even attempted.
Two hosts mounted the LUN and the filesystem is now damaged. ext4, xfs and every other single-host filesystem cache metadata in memory and assume nothing else writes to the device. Two mounts means two independent caches over one set of blocks. There is no mount option that makes this safe — ro on one side reduces the damage but still returns stale data. If more than one host genuinely needs concurrent write access to the same blocks, you need a cluster filesystem such as GFS2 or OCFS2 with its own lock manager, or you need file-level sharing instead of block-level. Otherwise: one LUN, one owner, enforced by only creating one ACL.
You deleted the target but the initiator keeps trying to reconnect. Node records outlive the target. Log out and delete the record explicitly:
iscsiadm -m node -T iqn.2026-07.com.example:disk1 -p <target-ip> --logout
iscsiadm -m node -o delete -T iqn.2026-07.com.example:disk1 -p <target-ip>
Without the delete, iscsid retries the dead portal at every boot and logs failures forever.
Throughput is far below what the disks can do. Before blaming iSCSI, work out whether the ceiling is the network. A single gigabit path caps around 110 MB/s regardless of what is behind the target, and if storage shares that path with application traffic you will see latency spikes under load rather than a clean lower number. Measure the raw path first, then compare against a local dd on the target’s own volume. Jumbo frames help, but only if the MTU is consistent on both hosts and every switch between them — a mismatch produces silent fragmentation or dropped frames that look like random stalls.
When this is the wrong approach
iSCSI is the right tool when one host needs a disk that physically lives somewhere else. It is the wrong tool more often than people expect.
If several machines need to read and write the same files, you want file-level sharing, not block-level: set up an NFSv4 server and let one host own the filesystem while the others speak a protocol designed for concurrent access. If the data is write-once and read-often — backups, artifacts, media — object storage costs less and needs no session state. If you are on a cloud or virtualization platform that already offers managed block volumes, use those: you get the same block device with snapshots and live resize handled for you, and you are not the one on the hook when the target host reboots.
And if you have no dedicated storage network, think twice. Every iSCSI session is a kernel-level dependency on a TCP connection. When that connection degrades, the initiator does not see a slow disk — it sees SCSI timeouts, and processes go into uninterruptible sleep waiting on I/O that may never complete.
If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.