How To: Synology iSCSI LUN for Proxmox Backup Server Datastore

If you have a Synology NAS and want to use it with Proxmox Backup Server (PBS), you have two primary options for your datastore: NFS or an iSCSI LUN. If you want to use NFS storage, check out my previous article: How To: Setup Synology NFS for Proxmox Backup Server Datastore . However, the NFS datastore can be finicky and does not always have the best performance. I have now migrated all of my PBS datastores to use iSCSI LUNs. This article walks you through the entire process. 

If you don’t have a Synology NAS, but have another NAS that supports sharing of iSCSI LUNs, 95% of the process will be the same. For reference I’m using DSM 7.2.2 and Proxmox Backup Server 4.0. However, this is a pretty generic configuration, so it should work across versions. 

Warning: This procedure ONLY works if Proxmox Backup Server is running as a VM (or bare metal). It does NOT work if PBS is a LXC. Mounting LUNs in an LXC is very complex and error prone and I do NOT recommend it. 

Related Synology Posts

As part of my Proxmox Backup Server 4.0 and Proxmox VE 9.0 series, check out these related posts:

Synology iSCSI LUN Creation

  1. Login to your Synology and open the SAN Manager application.
  2. On the left click on LUN, then Create.
  3. Give the LUN a name and description, pick the location, and capacity. 
  4. Select Thin Provisioning, and check the Space reclamation box. 

5. Click Next, click Next on the Configure SAN protocol page. 
6. Leave Allow all selected, click Next. Click Done.
7. Edit the LUN, click on the Cache tab, and check the FUA/Sync box. Click Save.

8. Click on iSCSI in the left pane.
9. Select the iSCSI target and click Edit.
10. On the General tab enable CHAP.
11. Enter a username and password (MUST be 12-16 characters).
12. Click Save.

Install Open iSCSI

1. Open a shell via the GUI or SSH into your Proxmox Backup server VM. Let’s install open iSCSI, then configure it to start on each boot.

				
					apt update
apt install open-iscsi
modprobe iscsi_tcp
lsmod | grep iscsi_tcp
modinfo iscsi_tcp
echo "iscsi_tcp" >> /etc/modules
echo "scsi_transport_iscsi" >> /etc/modules

				
			

2. Reboot the VM, and open another shell. Run the following command to verify the iSCSI module is loaded:

				
					modinfo iscsi_tcp
				
			

3. Now let’s make sure iSCSI is started at boot:

				
					sed -i 's/node.startup = manual/node.startup = automatic/g' /etc/iscsi/iscsid.conf
				
			

Mounting the iSCSI LUN

Note: 10.13.2.230 is the IP address of my Synology NAS. Replace with the IP of your NAS. 

  1. Let’s list all of the available iSCSI LUNs on your NAS. If your NAS supports IPv6, you may get multiple listings.
				
					 iscsiadm --mode discovery --portal 10.13.2.230 --type sendtargets
				
			

2. Let’s mount the iSCSI LUN on the IPv4 portal. Change the CHAP username and password as needed:

				
					iscsiadm -m node --targetname=iqn.2000-01.com.synology:DS923.Target-1.2c0d1f17e14 --op=update --name node.session.auth.authmethod --value=CHAP
iscsiadm -m node --targetname=iqn.2000-01.com.synology:DS923.Target-1.2c0d1f17e14 --op=update --name node.session.auth.username --value=pbs
iscsiadm -m node --targetname=iqn.2000-01.com.synology:DS923.Target-1.2c0d1f17e14 --op=update --name node.session.auth.password --value="password123"
iscsiadm -m node --targetname=iqn.2000-01.com.synology:DS923.Target-1.2c0d1f17e14 --portal=10.13.2.230 --login
				
			

3. Let’s look for the Linux disk device that the LUN is mounted to.

				
					iscsiadm -m session -P 3 | grep Attached
				
			

4. Create a partition table for your new device (sdb).

				
					fdisk /dev/sdb
				
			

n # Create new partition
p # Primary partition
1 # Partition number
# Press Enter for default first sector
# Press Enter for default last sector (use whole disk)
w # Write changes and exit

5. Format the disk with EXT4.

				
					 mkfs.ext4 /dev/sdb1
				
			

6. Let’s make a directory to mount the new LUN.

				
					mkdir -p /mnt/datastore/synology923
				
			

7. Mount the LUN.

				
					mount /dev/sdb1 /mnt/datastore/synology923/
				
			

8. We need to grab the UUID for the new LUN. Look for /dev/sdb1 and copy the UUID to the clipboard.

				
					blkid
				
			

9. Configure systemd mount with automatic retry. Feel free to change the file name, but it needs to be consistent throughout the rest of the commands.

				
					nano /etc/systemd/system/mnt-datastore-synology923.mount

				
			

10. Paste this text into nano and modify as needed for your parameters (UUID and mount path).

				
					[Unit]
Description=Synology 923 iSCSI Storage Mount
Requires=network-online.target iscsid.service
After=network-online.target iscsid.service
Wants=mnt-datastore-synology923.automount

[Mount]
What=/dev/disk/by-uuid/3f0c8c0d-470a-4746-aeb3-1f4f0597d272
Where=/mnt/datastore/synology923
Type=ext4
Options=_netdev,auto,nofail,defaults

[Install]
WantedBy=multi-user.target
				
			

11. Create the automount unit.

				
					nano /etc/systemd/system/mnt-datastore-synology923.automount
				
			

12. Add this text (change path as needed):

				
					[Unit]
Description=Automount Synology 923 iSCSI Storage
Requires=network-online.target

[Automount]
Where=/mnt/datastore/synology923
TimeoutIdleSec=0

[Install]
WantedBy=multi-user.target
				
			

13. Enable system services:

				
					systemctl daemon-reload
systemctl enable mnt-datastore-synology923.automount
systemctl start mnt-datastore-synology923.automount
				
			

14. Verify:

				
					systemctl status mnt-datastore-synology923.automount
systemctl status mnt-datastore-synology923.mount
				
			

15. Add robust iSCSI session monitoring:

				
					nano /usr/local/bin/check-iscsi-session.sh
				
			

16. Add this text (change iSCSI target and portal as needed):

				
					#!/bin/bash
TARGET="iqn.2000-01.com.synology:DS923.Target-1.2c0d1f17e14"
PORTAL="10.13.2.230:3260"

if ! iscsiadm -m session | grep -q "$TARGET"; then
    iscsiadm -m node -T "$TARGET" -p "$PORTAL" --login
fi
				
			

17. Save the file and run the following commands:

				
					chmod +x /usr/local/bin/check-iscsi-session.sh
echo "*/5 * * * * /usr/local/bin/check-iscsi-session.sh" | crontab -
				
			

18. Create the Proxmox backup datastore (change name and path as needed):

				
					proxmox-backup-manager datastore create Synology-923 /mnt/datastore/synology923
				
			

19. Reboot the PBS server, login, and verify the new datastore is online.

Extending the LUN

LUNs are a fixed size, so if your backup datastore gets low on space, you will need to either prune your backups more deeply, or extend the LUN. Here’s the procedure to do an on-line LUN extension:

  1. Login to your Synology, open SAN Manager.
  2. In the left pane click on LUN.
  3. Locate your PBS LUN, click on Edit, then enter the new size.
  4. Click Save.

1. SSH into PBS and run the following commands (change sdb as needed):

				
					apt update
apt install cloud-guest-utils
echo 1 > /sys/block/sdb/device/rescan && growpart /dev/sdb 1 && resize2fs /dev/sdb1
fdisk -l /dev/sdb


				
			

2. Very the LUN has expanded to the new size:

Create Synology Host

Once your Proxmox backup server has logged into the iSCSI portal and mounted the LUN, we can create a Synology “host”.

  1. Login to your Synology and open the SAN Manager.
  2. Click on iSCSI and find your PBS LUN.
  3. Click on Create Host.

4. Click on Start.
5. Enter a host name, description, and change the OS to Linux.
6. Click Next on the permissions screen.
7. Click Done.

Synology LUN Snapshots

  1. If you want periodic snapshots taken of your LUN, click on Snapshot in the left pane.
  2. Click on Settings.
  3. Tick the Enable box.
  4. Setup the schedule as desired. If your Synology supports immutable snapshots, you can also enable them here too.
  5. Click on Retention.
  6. Select the retention policy that meets your needs.
  7. Click OK. 

Summary

Configuring an iSCSI LUN on your Synology NAS to be used by Proxmox Backup Server 4.0 is not too difficult. The most tedious part is automating the mounting of the LUN, and adding checks to re-mount it should it go offline for any reason. Using an iSCSI LUN for Proxmox backups is faster than a NFS share, and has been more reliable for me as well.

Related Posts

Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments