From Web Design to ERP — Your IT Partner

Proxmox Swap Usage High? Find the Culprit VM Fast

The trap: A Proxmox host with 192GB of RAM and "83GB available" was still pushing 11GB into swap. The available figure in free -m counts reclaimable cache as headroom — it doesn't mean you have that much room above swap. Here's how to find which VM is actually responsible, without taking anything offline.

Random VM pauses — 2 to 15 seconds of nothing, then it resumes — are one of the most confusing Proxmox symptoms to diagnose, because the VM doesn't crash and the host's own dashboard often looks fine at a glance. The usual cause: the kernel quietly swapped out the least-recently-used memory pages from an over-allocated VM, and now something is swap-faulting them back in.

Confirming It's Actually Swap

free -m

# total used free shared buff/cache available

# Mem: 192105 108584 3923 39 69224 83521

# Swap: 15359 11380 3979

83GB "available" looks safe. It isn't a reliable safety margin — it includes buffer/cache, which VMs are also actively competing for. The number that actually tells you there's a problem is the 11.3GB already in swap: that only happens after the kernel genuinely couldn't fit everything in RAM at some point.

Finding the Responsible VM

Each running VM is a kvm process — check swap usage per-process directly from /proc:

for pid in $(ls /proc | grep '^[0-9]'); do

swap=$(grep VmSwap /proc/$pid/status 2>/dev/null | awk '{print $2}')

[ -n "$swap" ] && [ "$swap" -gt 0 ] \

&& echo "$swap $pid $(cat /proc/$pid/comm 2>/dev/null)"

done | sort -rn | head -15

Then map the heaviest PID back to a VM ID with qm list or by checking the process cmdline for its VMID. In one real case, a single PID with 6.4GB of swap turned out to be a VM allocated 65GB of RAM — the single largest consumer on the host by a wide margin.

The Math That Explains It

Line itemAmount

Physical host RAM192 GB

Total RAM allocated across running VMs~154 GB

Host OS overhead~8 GB

True headroom before swap pressure~30 GB

With allocation-vs-physical this close, the moment VMs actually use what they're allocated at the same time, the kernel starts swapping — the 69GB of buffer/cache in the "available" figure doesn't help once VM memory demand crosses that real ~30GB line.

Five Fixes, in the Order to Try Them

1. Lower host swappiness

sysctl vm.swappiness=10

echo 'vm.swappiness = 10' >> /etc/sysctl.d/99-proxmox-tuning.conf

Default is 60 — the kernel starts swapping at 40% pressure. At 10, it evicts cheap-to-evict buffer/cache first and only swaps VM memory pages (expensive) when genuinely out of room.

2. Stop VMs that are running but idle

for vmid in $(qm list | awk 'NR>1 && $3=="running" {print $1}'); do

pid=$(qm status $vmid | grep -oP 'pid: \K\d+')

echo "VM $vmid: CPU $(ps -p $pid -o %cpu= 2>/dev/null)%"

done

A VM sitting at 0% CPU for hours while holding a large RAM allocation is a strong stop candidate — qm shutdown <VMID>, or qm stop if unresponsive.

3. Right-size over-allocated VMs

# Check actual in-guest usage first

qm guest exec <VMID> -- free -m

# Then reduce

qm set <VMID> -memory 49152

qm reboot <VMID>

4. Check for wasted huge pages

grep -i hugepages /proc/meminfo

# HugePages_Total: 512 → 1GB reserved, may be sitting unused

echo 0 > /proc/sys/vm/nr_hugepages # if confirmed unused

5. Force a reclaim without rebooting anything

# I/O intensive — do this during low-traffic hours

sysctl vm.swappiness=0

watch -n5 free -m # watch swap fall

sysctl vm.swappiness=10 # restore after

One thing worth knowing: router VMs (MikroTik CHR) are a special case — RouterOS is an embedded OS that handles large routing tables in kilobytes, often sitting over 90% free on a 4GB allocation. Don't shrink CHR below 1GB though; RouterOS has its own initialization RAM requirement regardless of actual usage.

A Sane Over-Provisioning Ratio

SettingRecommendedWhy

vm.swappiness10Prefer evicting cache over VM memory

Swap partition size= physical RAMRoom for genuine OOM emergencies

BallooningOff for router VMs, optional elsewhereRouters need consistent memory; dev VMs can flex

Max over-allocation ratio1.2:1Beyond ~1.5:1, swap pressure becomes routine, not occasional

Simple Ongoing Monitoring

# Daily one-liner

free -m | awk 'NR==3{printf "Swap: %d MB / %d MB (%.0f%%)\n", $3, $2, $3/$2*100}'

# Cron alert if swap crosses a threshold

0 8 * * * root SWAP=$(free -m | awk 'NR==3{print $3}'); \

[ $SWAP -gt 8000 ] && echo "WARNING: swap at ${SWAP}MB" | mail -s "Swap Alert: $(hostname)" [email protected]

FAQ: Does reducing swappiness eliminate swap entirely?

Not if the host is genuinely over-provisioned — it reduces unnecessary swapping, but if allocated RAM across running VMs truly exceeds physical RAM under real load, some swap use is unavoidable without adding memory or reducing allocations. Swappiness tuning alone got one fleet from 11GB down to under 2GB within 30 minutes, without restarting anything.

FAQ: Is ballooning the fix for this instead?

Ballooning helps the host reclaim genuinely idle guest memory dynamically, which is related but not the same problem — see our separate write-up on the Proxmox-shows-100%-but-Windows-shows-21% confusion that ballooning settings cause.

Running a Proxmox host that's tight on headroom and want a second opinion before it turns into unplanned downtime? Get in touch.