Proxmox - configure iscsi over zfs

This guide assumes Proxmox as the hypervisor and a Debian-based storage server with ZFS. Adjust commands and paths for your environment.

Proxmox Server Configuration

Create a directory for the private key used for secure communication between Proxmox and the storage server:

mkdir /etc/pve/priv/zfs

Generate SSH key

ssh-keygen -f /etc/pve/priv/zfs/192.168.88.25_id_rsa

Copy key to storage node

ssh-copy-id -i /etc/pve/priv/zfs/192.168.88.25_id_rsa.pub [email protected]

Test SSH connection

ssh -i /etc/pve/priv/zfs/192.168.88.25_id_rsa [email protected]

Verify that the SSH connection works without errors.

Update the Proxmox storage configuration. Edit /etc/pve/storage.cfg and add (example):

zfs: zfs-pool-name
        blocksize 4k
        iscsiprovider LIO
        pool pool-name
        portal 192.168.88.25
        target iqn.2022-10.protolab.me.zfs-test:node-protolab
        content images
        lio_tpg tpg1
        nowritecache 1
        sparse 0

Get initiator name

On the Proxmox node:

cat /etc/iscsi/initiatorname.iscsi
# Example: iqn.1993-08.org.debian:01:16b2296f83c

Restart Proxmox services

systemctl restart pvedaemon && systemctl restart pveproxy && systemctl restart pvestatd

Debian storage server

Update and install ZFS

apt update && apt upgrade
sed -r -i'.BAK' 's/^deb(.*)$/deb\1 contrib/g' /etc/apt/sources.list
apt update
apt install linux-headers-amd64 zfsutils-linux zfs-dkms zfs-zed

Load ZFS module

modprobe zfs

Create ZFS pool (replace disks with yours)

# Example:
zpool create -f -d -m none -o ashift=12 -O atime=off -o feature@lz4_compress=enabled storage /dev/sdX /dev/sdY
# Or:
zpool create -o ashift=12 -O compression=lz4 -O atime=off -O xattr=sa -O acltype=posix storage SanDisk_XXX

Create dataset

# Example: -o compression=off -o dedup=off -o volblocksize=32K -V 1000G storage/cloud

 ls -l /dev/zvol/storage/cloud
.. /dev/zvol/storage/cloud -> ../../zd0

Configure iSCSI target

Install targetcli

apt -y install targetcli-fb 

Create block object and target (targetcli)

cd backstores/block
/backstores/block> create md_block0 /dev/zvol/storage/cloud
cd /iscsi
create iqn.2022-10.protolab.me.zfs-test:node-protolab

cd iqn.2023-11.protolab.me.zfs-cloud:node-protolab/tpg1/
/tpg1> set attribute authentication=0
cd luns
create /backstores/block/md_block0

cd ../portals
delete 0.0.0.0 ip_port=3260
create 192.168.88.25 3260

cd ../acls
# cat /etc/iscsi/initiatorname.iscsi from proxmox node
create iqn.1993-08.org.debian:01:16b2296f83c

After configuring the iSCSI target, you should be able to add the storage in Proxmox and deploy VMs.