Proxmox Swap Configuration: Tuning, ZFS Caveats, and Sizing Guide
Configure and optimize swap on Proxmox VE. Covers default swap after install, vm.swappiness tuning, ZFS and swap conflicts, swap file vs partition, sizing recommendations, and monitoring swap usage.
Default Swap After Proxmox Installation
The Proxmox VE installer creates swap space automatically during installation, but the size and type depend on which filesystem you chose. Understanding what was set up and whether it suits your workload is the first step toward proper swap management on a virtualization host.
# Check your current swap configuration
swapon --show
# NAME TYPE SIZE USED PRIO
# /dev/dm-1 partition 7.6G 0B -2
# See total swap in context with RAM
free -h
# total used free shared buff/cache available
# Mem: 62Gi 4.2Gi 45Gi 12Mi 13Gi 57Gi
# Swap: 7.6Gi 0B 7.6Gi
# Check what the installer created
cat /etc/fstab | grep swap
# /dev/pve/swap none swap sw 0 0
# For LVM-based installs (default with ext4/xfs):
lvs | grep swap
# swap pve -wi-ao---- 7.63g
With a standard LVM install, Proxmox creates a swap logical volume sized between 4-8 GB depending on the installer version and disk size. With a ZFS install, the situation is different and requires special attention.
The vm.swappiness Parameter
The vm.swappiness parameter controls how aggressively the Linux kernel moves memory pages from RAM to swap. The value ranges from 0 to 200 (0 to 100 on older kernels). A lower value keeps more data in RAM; a higher value swaps more aggressively.
# Check current swappiness
cat /proc/sys/vm/swappiness
# Default: 60
# For a Proxmox virtualization host, lower values are usually better
# vm.swappiness=10 means: only swap when RAM is nearly exhausted
sysctl vm.swappiness=10
# Make it persistent
echo "vm.swappiness = 10" >> /etc/sysctl.d/swap-tuning.conf
sysctl -p /etc/sysctl.d/swap-tuning.conf
# Recommended values for Proxmox:
# 10 - Conservative: swap only under memory pressure (recommended for most setups)
# 1 - Minimal: avoid swapping almost entirely (good if you have plenty of RAM)
# 0 - Emergency only: kernel will still swap to avoid OOM kills
# 60 - Default: too aggressive for virtualization hosts
# For ZFS-based Proxmox installs, Proxmox already sets this to 10:
cat /etc/sysctl.d/99-proxmox-zfs.conf 2>/dev/null
# vm.swappiness = 10
On a virtualization host, swapping VM memory pages to disk causes severe performance degradation for the affected VMs. The guest operating system does not know its memory was swapped, so it cannot compensate. Keeping swappiness low ensures that swap is only used as a safety net, not as regular memory extension.
ZFS and Swap: Critical Warning
If your Proxmox installation uses ZFS for the root filesystem, do not place swap on ZFS. ZFS's copy-on-write design and ARC cache behavior interact poorly with swap, potentially causing a deadlock where the system needs to write to swap but ZFS needs more memory to do so.
# WRONG: Do not create a zvol for swap
# zfs create -V 8G rpool/swap <-- DO NOT DO THIS
# Check if you accidentally have swap on ZFS
swapon --show
# If TYPE shows "partition" or "file" on a ZFS dataset, fix it immediately
# CORRECT approach: Use a dedicated non-ZFS partition for swap
# If you have a spare partition or disk:
mkswap /dev/sdX2
swapon /dev/sdX2
echo "/dev/sdX2 none swap sw 0 0" >> /etc/fstab
# Alternative: Use a small SSD/NVMe partition for swap
# During Proxmox installation with ZFS, the installer may create
# a small swap partition outside ZFS on the boot disk
# If you have no swap on a ZFS system (common and acceptable):
free -h | grep Swap
# Swap: 0B 0B 0B
# This is fine if you have sufficient RAM and don't overcommit
Many Proxmox users with ZFS run without swap entirely and instead ensure they have enough physical RAM for their workload. This is a valid approach, especially if you avoid memory overcommit.
Swap File vs Swap Partition
On ext4 or XFS installations, you can use either a swap partition (logical volume) or a swap file. Each has trade-offs.
# Check current swap type
swapon --show
# TYPE column shows "partition" or "file"
# Creating a swap file (ext4/XFS only, NOT on ZFS or Btrfs)
# Allocate a 4 GB swap file
dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progress
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
# Make persistent
echo "/swapfile none swap sw 0 0" >> /etc/fstab
# Verify
swapon --show
# Adjusting swap partition size (LVM)
# Extend an existing swap LV
swapoff /dev/pve/swap
lvextend -L 16G /dev/pve/swap
mkswap /dev/pve/swap
swapon /dev/pve/swap
# Shrink an existing swap LV
swapoff /dev/pve/swap
lvreduce -L 4G /dev/pve/swap
mkswap /dev/pve/swap
swapon /dev/pve/swap
Swap partitions (or LVM logical volumes) offer slightly better performance due to contiguous allocation. Swap files are more flexible since you can resize them without repartitioning. On a modern NVMe drive, the performance difference is negligible.
Sizing Recommendations
Swap sizing for a Proxmox host depends on total RAM and whether you overcommit memory:
- 16 GB RAM or less: 4-8 GB swap. Small hosts benefit from swap as a safety buffer.
- 32-64 GB RAM: 4-8 GB swap. Enough to catch occasional spikes without significant disk thrashing.
- 128 GB+ RAM: 2-4 GB swap, or none at all. With this much RAM, swap is rarely needed and would mask real capacity problems.
- ZFS with no spare partitions: 0 GB swap is acceptable. Focus on leaving 50% of RAM free for the ZFS ARC cache.
Monitoring Swap Usage
Regular monitoring helps you catch memory problems before they affect VM performance.
# Quick swap status
free -h
# Which processes are using swap (top swap consumers)
for pid in /proc/[0-9]*; do
swap=$(awk '/VmSwap/{print $2}' "$pid/status" 2>/dev/null)
if [ "${swap:-0}" -gt 0 ]; then
name=$(awk '/Name/{print $2}' "$pid/status" 2>/dev/null)
echo "$swap kB - $name (PID $(basename $pid))"
fi
done | sort -rn | head -10
# Watch swap activity in real time
vmstat 5
# Look at the "si" (swap in) and "so" (swap out) columns
# Non-zero values mean active swapping is occurring
# Check swap I/O over time
sar -W 1 10
# Shows pswpin/s and pswpout/s
If you see consistent swap usage on your Proxmox host, it is a signal to either reduce VM memory allocations, add physical RAM, or enable ballooning. Monitoring tools like ProxmoxR can help you keep track of host-level memory pressure across your nodes so you can catch these issues before they impact your virtual machines.
Take Proxmox management mobile
All the features discussed in this guide — accessible from your phone with ProxmoxR. Real-time monitoring, power control, firewall management, and more.