Distroname and release: Debian Buster
ISCSI and ZFS ZVOL
An short guide for using an ZVOL as ISCSI storage device.
The ISCSI setup consists of an Server (ISCSI Target), and client (ISCSI Initiator)
Prerequisite: The ZVOL must exist already.
ISCSI Target (Server)
There are multiple options for the ISCSI target, but we will be use using LIO (kernel space).Install targecli and iscsi client tools. Client tools is not required, but nice to have to debug (open-iscsi)
apt-get install targetcli-fb open-iscsiNow we can use the targecli CLI.
Create the backstore blockdevice! We will be using the already created ZVOL here! (Notice the path, we are using).
targetcli > cd /backstores/block /backstores/block> create block1 /dev/zvol/DATA/zvol_workstation Created block storage object block1 using /dev/zvol/DATA/zvol_workstation.Create the iSCSI Qualified NAME (IQN), still using the targetcli interface. See think link for IQN clarification.
If you are lazy, just use "create" without arguments.
> cd /iscsi/ /iscsi/> create iqn.2019-10.local.linuxlasse.iscsi:storage01Now the IQN is created, we need to create an LUN on the previously created backstore, and again in the tagetcli interface.
cd /iscsi/iqn.2019-10.local.linuxlasse.iscsi:storage01/tpg1/luns /iscsi/iqn.20...e01/tpg1/luns> create /backstores/block/block1You must create an ACL for each client that needs to connect.
On linux initiator , find the initiatorname, like so! (requires open-iscsi tools):
grep ^InitiatorName /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.1993-08.org.debian:01:3e1beb39d22e(New names can be generated with the iscsi-iname command) Then in the targetcli interface, create the acesslist.
> cd /iscsi/iqn.2019-10.local.linuxlasse.iscsi:storage01/tpg1/acls > create iqn.1993-08.org.debian:01:3e1beb39d22e
ISCSI Client ( initiator )
If not already installed on the client.
apt-get install open-iscsi
Discover available targets, can be done like so.
iscsiadm -m discovery -t sendtargets -p 192.168.10.11
192.168.10.11:3260,1 iqn.2019-10.local.linuxlasse.iscsi:storage01
Connect to the ISCSI blockdevice
iscsiadm --mode node --targetname iqn.2019-10.local.linuxlasse.iscsi:storage01 --portal 192.168.10.11:3260 --login
Looking in /var/log/messages should show attached scsi.
grep Attached /var/log/messages
Oct 9 15:14:42 prodigy kernel: [2176700.847504] sd 9:0:0:0: Attached scsi generic sg10 type 0
Oct 9 15:14:42 prodigy kernel: [2176700.853664] sd 9:0:0:0: [sdk] Attached SCSI disk
Done, now you can use this as an normal disk, now format it with fdisk/cfdisk/parted or whatever.
You can disconnect the ISCSI device from the initiator like so.
iscsiadm --mode node --targetname iqn.2019-10.local.linuxlasse.iscsi:storage01 --portal 192.168.10.11:3260 --logout