Using ZFS disk space to increase swap

harmonyp

Member
Nov 26, 2020
196
4
23
47
Hello,

I currently have 4 disks allocated to RAID 10 ZFS and require more swap space on my node and need to use some of that allocated ZFS disk. I have come across this https://askubuntu.com/questions/228149/zfs-partition-as-swap

Which says all I need to do to add 10GB swap is run

Code:
zfs create pool/swap -V 10G -b 4K
mkswap -f /dev/pool/swap
swapon /dev/pool/swap

Is this advised against? I can see there is an issue that can cause a deadlock https://github.com/openzfs/zfs/issues/7734 how would that happen and how can I prevent it with Proxmox?
 
Last edited:
AFAIK the deadlock issue is still present and as indicated in the issue-report on github - quite difficult to clear up sensibly.
I would recommend against running swap on a ZVOL - if possible either add more ram, or a new disk - else if you can or have some unpartitioned space on the disk you can create a partition for it and use that as swap

I hope this helps!
 
AFAIK the deadlock issue is still present and as indicated in the issue-report on github - quite difficult to clear up sensibly.
I would recommend against running swap on a ZVOL - if possible either add more ram, or a new disk - else if you can or have some unpartitioned space on the disk you can create a partition for it and use that as swap

I hope this helps!
How does this deadlock happen though? Does it only happen if swap uses too much of the ZFS ZVOL disk because I have lots free (currently using 1.5TB of 6TB)
 
Hi,

You can create a dedicated dataset (cache metadata only). Then create a plain file with fallocate/dd (with desired size) and use it for swap.

mkswap /rpool/dataset/file-swap
swapon /rpool/dataset/file-swap.

Then add this file on fstab.

Good luck /Bafta !
 
Hi,

You can create a dedicated dataset (cache metadata only). Then create a plain file with fallocate/dd (with desired size) and use it for swap.

mkswap /rpool/dataset/file-swap
swapon /rpool/dataset/file-swap.

Then add this file on fstab.

Good luck /Bafta !
That would not cause the lockup issues?