How much swap are we using in 2025? With ZFS?

pugglewuggle

New Member
Jan 20, 2025
7
0
1
And how are you configuring swap in 2025? How much swap space? What kind of swap? parition? zram?

Example: host has 64GB RAM and NVMe SSD storage.

And how would this be affected if using ZFS RAID1 for mirrored NVMe system drives (I know no swap can be used for ZFS so if you want swap you need to leave space reserved then do an LVM RAID1 swap partition on the rest of the SSDs)?
 
Hello pugglewuggle! I just want to mention that while there are several recommendations in the PVE documentation about swap on ZFS, there are some unsolved issues, so you may want to reconsider using swap on ZFS and use enough RAM instead. While you didn't explain your use case, 64 GB RAM should be enough for many use cases, so you may want to disable swap.
 
This!

Of course I do my best to avoid the need of swap. If you need to swap then your hardware needs an upgrade - resources like CPU-power, NICs, Storage can be over-committed. For RAM this has to / should be avoided!
 
Last edited:
  • Like
Reactions: Johannes S
Look, guys. In my case swapiness =0 and system has 128G of RAM and storage is on zfs (2xNVME mirrored)
Swap is off and host is ok BUT in one CT (lxc) db software requires formally a presence of swap over 500M.

How i can fullfill that requerement as "cheaper" as possible? Or I should follow
Code:
# To set swap on a zfs drive:
zfs create -V 8G -b $(getconf PAGESIZE) -o logbias=throughput -o sync=always -o primarycache=metadata -o com.sun:auto-snapshot=false VMs/swap

mkswap -f /dev/zvol/VMs/swap
swapon /dev/zvol/VMs/swap

# IN FSTAB
/dev/zvol/VMs/swap none swap discard 0 0
 
Last edited: