Frequently Asked Question

What KVM is using all my swap on proxmox?
Last Updated a year ago

Swap usage can be an issue, especially when you come in to find it at 98% and everything is chugging. There's no easy way in proxmox to see who's using all that swap and whilst tools like smem can show you, the information is vague. 

The following script, which we call showswap.sh and place in ~ shows you exactly who's using your swap so you can restart it. 

#!/bin/bash
printf "%-10s %-8s %s\n" "SWAP" "PID" "COMMAND"
for pid in $(pgrep -x kvm); do
    swap=$(grep VmSwap /proc/$pid/status 2>/dev/null | awk '{print $2}')
    if [ ! -z "$swap" ] && [ "$swap" -gt 0 ]; then
        cmd=$(ps -p $pid -o args= | cut -c1-80)
        printf "%-10s %-8s %s\n" "$((swap/1024)) MB" "$pid" "$cmd"
    fi
done | sort -hr

Once you've put this in showswap.sh, don't forget to make it executable with

chmod +x showswap.sh

and then execute it with

./showswap.sh

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.

This website relies on temporary cookies to function, but no personal data is ever stored in the cookies.
OK
Powered by GEN UK CLEAN GREEN ENERGY

Loading ...