iSCSI carries SCSI disk commands over TCP/IP, so a server can use a disk on another machine as if it were local. It is the classic way to build a simple SAN for virtualization. This guide shows how to set up iSCSI on Linux with a target (storage server) and an initiator (client).
Before you start
- Two Linux servers on a private, fast network; a dedicated storage VLAN is recommended.
- A spare disk, partition or LVM volume on the target server to share.
- An iSCSI LUN should be used by one host at a time unless you use a cluster-aware filesystem or LVM setup.
Create the target with targetcli
sudo apt install -y targetcli-fbRHEL family: sudo dnf install -y targetcli. Then run sudo targetcli and enter:
/backstores/block create name=vmdisk1 dev=/dev/vg_storage/vmdisk1
/iscsi create iqn.2025-12.com.example:storage1
/iscsi/iqn.2025-12.com.example:storage1/tpg1/luns create /backstores/block/vmdisk1
/iscsi/iqn.2025-12.com.example:storage1/tpg1/acls create iqn.2025-12.com.example:kvm1
saveconfig
exitEnable the service so the config loads at boot (rtslib-fb-targetctl on Debian/Ubuntu, target on RHEL), and allow TCP port 3260 only from initiators.
Configure the initiator
sudo apt install -y open-iscsiSet the initiator name to match the ACL in /etc/iscsi/initiatorname.iscsi:
InitiatorName=iqn.2025-12.com.example:kvm1sudo systemctl restart iscsidDiscover and log in:
sudo iscsiadm -m discovery -t sendtargets -p 10.10.0.5sudo iscsiadm -m node -T iqn.2025-12.com.example:storage1 -p 10.10.0.5 --loginA new disk appears in lsblk. Make login automatic: sudo iscsiadm -m node -T iqn.2025-12.com.example:storage1 --op update -n node.startup -v automatic.
Add CHAP authentication
In targetcli under the ACL, set set auth userid=kvm1 password=LongSecret. On the initiator, set node.session.auth.authmethod = CHAP and the same username and password in /etc/iscsi/iscsid.conf or per node with iscsiadm --op update.
Use it for VMs
- Use the LUN directly as a raw VM disk (
/dev/disk/by-path/...) for best stability of device names. - Or create an LVM volume group on it and use a libvirt logical pool; see LVM storage pool for KVM.
- For sharing across hosts with live migration, use shared LVM with locking, or prefer NFS/Ceph; see NFS shared storage.
Troubleshooting
- Login failed: authorization failure: initiator IQN does not match the ACL, or CHAP is wrong.
- No targets found: firewall blocks port 3260, or the target listens on another IP.
- Disk name changes after reboot: use
/dev/disk/by-pathorby-idin configs and fstab with_netdev.
Frequently asked questions
iSCSI or NFS for VMs?
iSCSI gives block devices with low overhead; NFS is simpler to share between hosts.
Do I need multipath?
For redundancy with two network paths, yes, using multipathd.
Can Windows connect to a Linux iSCSI target?
Yes, with the built-in iSCSI Initiator.
