vm.swappiness controls how aggressively the Linux kernel moves memory pages to swap versus keeping them in RAM — a single tunable with real, measurable performance impact depending on your workload.
# Check current value (0-100 scale) cat /proc/sys/vm/swappiness # Temporarily change it (resets on reboot) sudo sysctl vm.swappiness=10 # Make it permanent echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf sudo sysctl -p
What the Value Actually Means
- Default (60) — a balanced middle ground, reasonable for most desktop use
- Low (10-20) — the kernel prefers keeping data in RAM, swapping only when genuinely necessary; a common choice for database servers where swap latency directly hurts query performance
- High (80-100) — the kernel swaps more aggressively, keeping more RAM free for disk cache; occasionally useful on memory-constrained systems doing heavy file I/O
Setting swappiness to 0 doesn’t disable swap entirely — it just makes the kernel avoid swapping unless truly out of memory, which is different (and generally safer) than disabling swap outright, since a genuine out-of-memory condition without any swap at all leads directly to the kernel’s OOM killer terminating processes.