Proxmox Back Server ISCSI Automate Setup For Datastore

From the PBS command line, the following commands were used to test the connectivity between the PBS and iSCSI target and to manually setup ZFS.

iscsiadm -m discovery -t st -p "ip address Iscsi"
iscsiadm -m node --login
iscsiadm -m session -o show

“target iscsi take in session show” es. :×2:iscsi.qnap.3b0505

“ip address Iscsi” es. :

If successful, then setup the ZFS pool. Determine the disk using fdisk -l. I have determined that /dev/sda was the one to use.

zpool create -f "name of folder you want" /dev/sda
zpool list

After the ZFS is setup, you should be able to access /”folder created” from your system. Make note of the iSCSI connections, you’ll need them later.

Reboot. This will remove the iSCSI and make it easier to setup the iSCSI connections permanently.

After Reboot. Automatically start the iSCSI requires the following two commands and a modification to a config file.

iscsiadm --mode node -T "target iscsi take in session show" -p "ip address Iscsi" -o update -n node.startup -v automatic
iscsiadm --mode node -T "target iscsi take in session show" -p "ip address Iscsi" -o update -n node.conn[0].startup -v automatic
sed -i '/^node.startup = /s/manual/automatic/g' /etc/iscsi/iscsid.conf


Determine the disk for setup ZFS

systemctl list-units --all --full | grep disk | grep "ip address Iscsi"

Use the disk information you determined above for create zfs service at Start up

cat << 'EOF' > /etc/systemd/system/pbsbks-pool.service
After=dev-disk-by\x2dpath-ip\x2d"ip address Iscsi":3260\x2discsi\x2discsi\x2diqn.2004\\x2d431x2:iscsi.qnap.3b0505\x2dlun\x2d0.device
ExecStart=/usr/sbin/zpool import backups
ExecStartPost=/usr/bin/logger "started ZFS pool backups"
WantedBy=dev-disk-by\x2dpath-ip\x2d"ip address Iscsi":3260\x2discsi\x2discsi\x2diqn.2004\\x2d431x2:iscsi.qnap.3b0505\x2dlun\x2d0.device

insert on shell all box in one shot, copy and past from a text file after insert the correct parameters

Start the service

systemctl daemon-reload
systemctl enable pbsbks-pool
systemctl restart pbsbks-pool

The next time you reboot your system, the iSCSI will connect and the ZFS pool with be imported and the datastore you create will automatically remain without error.


davide Written by: