Frequently Asked Question
Swappiness is a Linux kernel setting (vm.swappiness) that controls how willing the kernel is to move memory pages out of RAM and into swap space. It takes a value from 0 to 100 (up to 200 on newer kernels using cgroup v2 semantics), and the default on most distributions, including Proxmox VE, is 60.
- High values (60 and above): the kernel swaps more readily, even when there is still free RAM, preferring to keep the page cache large.
- Low values (1 to 10): the kernel avoids swapping and only does so when memory is genuinely under pressure.
- 0: swapping is effectively avoided until the system is almost out of memory. On modern kernels this can make the OOM killer act sooner, so
1is generally the safer choice.
Why it matters for KVM on Proxmox
Each KVM guest runs as a QEMU process on the host. The guest's "RAM" is just anonymous memory belonging to that process, so the host kernel is free to swap it out like any other memory.
This causes several problems:
- Double memory management. The guest OS has its own idea of which pages are hot and cold. The host cannot see this, so it may swap out pages the guest is actively using.
- Hidden latency. A guest reads what it believes is RAM, but the host must first fetch the page from disk. Latency jumps from nanoseconds to milliseconds, and the guest has no idea why.
- Guest-level symptoms. Slow consoles, high I/O wait, timeouts, stalled databases, and apparent CPU steal, even though the guest's own memory graphs look healthy.
- Storage contention. Swap usually shares disks with VM storage (particularly on ZFS or a single SSD/HDD mirror). Swap I/O then competes with guest I/O, slowing everything further.
- Cascading failure. Swapping slows guests, slow guests cause retries and queued I/O, and this increases memory and storage pressure further. This is the "spiral of doom" described in the Out-Of-Memory Spiral of Doom FAQ.
- ZFS interaction. On ZFS hosts, the ARC cache competes with guests for RAM. A high swappiness value can lead the kernel to swap out guest memory while the system is also holding a large cache.
On a hypervisor, you generally want guest memory to stay in RAM and swap to be a last-resort safety net, not part of normal operation.
Check the current value
cat /proc/sys/vm/swappiness
or:
sysctl vm.swappiness
You can also check how much swap is in use:
free -h
swapon --show
Change the value temporarily
This takes effect immediately but is lost on reboot:
sysctl vm.swappiness=1
Make the change permanent
Create a drop-in file under /etc/sysctl.d/.
The command in the original question is missing the redirection operator (>), so it would not write to the file. The correct form is:
echo "vm.swappiness = 1" > /etc/sysctl.d/90-swappiness.conf
Alternatively, using tee, which also works with sudo:
echo "vm.swappiness = 1" | sudo tee /etc/sysctl.d/90-swappiness.conf
Apply the file without rebooting:
sysctl --system
Or load only that file:
sysctl -p /etc/sysctl.d/90-swappiness.conf
Verify
sysctl vm.swappiness
Expected output:
vm.swappiness = 1
Important notes
- Lowering swappiness does not clear existing swap. Pages already swapped out stay there until they are used again. To flush swap back into RAM (only do this if there is enough free memory):
swapoff -a && swapon -a
Check free -h first. If used swap exceeds available RAM, this can cause an out-of-memory condition and may take a long time on a busy host.
- Swappiness is not a fix for insufficient RAM. If the host is still swapping heavily at
vm.swappiness=1, it is over-committed. Reduce guest memory allocations, move guests to other nodes, or add RAM. - Avoid memory over-commitment on Proxmox hosts. Be cautious with ballooning and with the total of all assigned guest RAM plus ZFS ARC.
- Limit ZFS ARC if using ZFS, so it does not compete with guests for memory.
- Keep some swap configured. A small amount of swap, ideally on fast storage, gives the kernel somewhere to put genuinely idle pages. Setting swappiness to
1does not require removing swap. - Find out which guests are using swap with the
showswap.shscript described in the "What KVM is using all my swap on Proxmox?" FAQ, then restart the affected guests to release it. - Cluster nodes: the setting is per host. Apply it to every node in the cluster.
Quick reference
| Value | Behaviour |
|---|---|
60 |
Default. Swaps fairly readily, which is not ideal for hypervisors. |
10 |
Conservative. Swaps only under moderate memory pressure. |
1 |
Recommended for Proxmox hosts. Swaps only to avoid running out of memory. |
0 |
Swapping is almost entirely disabled until memory is nearly exhausted. Use with care. |
Proxmox support from the engineers who wrote this article
This article came out of a real case resolved by GEN engineers, not from upstream documentation. GEN have run Proxmox in production in our own UK data centres since 2015, and have been in enterprise IT for 37 years. If this one has not solved your problem, we can.
- 30 minute response, 24 hours a day, every day of the year on critical production infrastructure.
- No contracts. Buy hours, use hours. No minimum term and no notice period.
- Genuinely independent. We hold no software partner status with Proxmox or any other vendor, so nothing we recommend is shaped by a licence margin.
- UK based, in-house engineers. No outsourced first line.
Proxmox support · VMware to Proxmox migration · Proxmox training · Support rates
Registering a GEN account is free, so the route to an engineer is open before you need it. You only ever pay for the time you use.
