How to create a ZFS Swap Partition Proxmox

Swap on Linux will assist if your environment is running short on memory. Usually, during setup, most distributions configure a swap partition. When your RAM is a certain percentage used, the server will start to use the swap partition. SWAP can be of great benefit to users who run an NVMe Dedicated Server because it provides up to 30GB of additional memory you can use. In this article, we will deal with how to create a ZFS Swap Partition. See this guide if you want to create a SWAP partition on a Linux Server with no Proxmox.

ZFS is a filesystem used in Cloud environments, it offers great performance and added benefits over other filesystems like LVM and LVM thin. If you are using Proxmox and installed from ISO to use ZFS then you would need to follow this guide to also enable swap.

Create ZFS Swap Partition Proxmox

Create ZFS Swap Partition

First, create a volume. This will hold the swap data. On most systems you won’t need a large amount of swap so, something like 8GB would be sufficient. We’re using 20GB here. If you need to use different compression, change the compression= statement. Also, rpool/swap is the location of your ZFS pool. If you’re using something different, modify the code. The default should be fine for most users.

zfs create -V 20G -b $(getconf PAGESIZE) -o compression=zle \
      -o logbias=throughput -o sync=standard \
      -o primarycache=metadata -o secondarycache=none \
      -o com.sun:auto-snapshot=false rpool/swap

So now in the console, you will see the ZFS Swap Partition has been created.

Format Proxmox ZFS Swap Partition

Using mkswap, now we format the drive. If you are using a different pool name, just like above, modify the location of the pool.

mkswap -f /dev/zvol/rpool/swap

Mount ZFS Swap Drive

Now, to ensure the drive is mounted on boot we add the following lines to the fstab. Again, if you are using a custom location for the ZFS pool, ensure you modify the code.

nano /etc/fstab

/dev/zvol/rpool/swap none swap defaults 0 0

Enable Proxmox ZFS Swap

Finally, you can enable the swap. There is no need to reboot after completing this.

swapon -av

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button