Proxmox - configure iscsi over zfs


This guide assumes a specific setup with Proxmox as the hypervisor and a Debian-based storage server using ZFS. Adjust the commands and configurations based on your environment and requirements.


Proxmox Server Configuration

Create a Directory for 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 the generated SSH key to the root user on the storage node :

ssh-copy-id -i /etc/pve/priv/zfs/192.168.88.25_id_rsa.pub root@192.168.88.25

Test SSH Connection:

ssh -i /etc/pve/priv/zfs/192.168.88.25_id_rsa root@192.168.88.25

Verify that the SSH connection works without errors.

Update the Proxmox storage configuration file to include the necessary settings for ZFS over iSCSI. nano /etc/pve/storage.cfg

ex.

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

Retrieve the initiator name, which will be used when creating an iSCSI target on the storage node:

cat /etc/iscsi/initiatorname.iscsi

ex.
iqn.1993-08.org.debian:01:16b2296f83c

Restart Proxmox Services:

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

Debian Storage Server Configuration

Ensure the Debian server is up to date.

apt update && apt upgrade

Install the necessary ZFS-related packages:

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 the ZFS kernel module.

modprobe zfs

Create a ZFS pool on the specified disk:

ex.

zpool create -f -d -m none -o ashift=12 -O atime=off -o feature@lz4_compress=enabled storage /dev/sdX /dev/sdY

zpool create -o ashift=12 -O compression=lz4 -O atime=off -O xattr=sa -O acltype=posix storage SanDisk_XXX

Create dataset:

ex.
zfs create -o compression=off -o dedup=off -o volblocksize=32K -V 1000G storage/cloud

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

#Configuring ISCSI target

Install targetcli

apt -y install targetcli-fb 

Creating a block storage object

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 configutring the ISCSI target you should be able to deploy your vms