Proxmox - configure iscsi over zfs
11 Jan 2022 #proxmoxThis 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/zfsGenerate SSH key
ssh-keygen -f /etc/pve/priv/zfs/192.168.88.25_id_rsaCopy 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 0Get initiator name
On the Proxmox node:
cat /etc/iscsi/initiatorname.iscsi
# Example: iqn.1993-08.org.debian:01:16b2296f83cRestart Proxmox services
systemctl restart pvedaemon && systemctl restart pveproxy && systemctl restart pvestatdDebian storage server
Update and install ZFS
apt update && apt upgradesed -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-zedLoad ZFS module
modprobe zfsCreate 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_XXXCreate 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 -> ../../zd0Configure 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:16b2296f83cAfter configuring the iSCSI target, you should be able to add the storage in Proxmox and deploy VMs.