Plainnotes

Should a small box use swap

2026-06-17 · 2 min readSystems

On a 1 GB machine, no swap means the OOM killer as soon as memory tightens; plenty of swap means the disk becomes memory and everything crawls.

What works: a small swapfile on SSD, 25–50% of RAM, with vm.swappiness=10 so the kernel only swaps under real pressure.

fallocate -l 512M /swapfile
chmod 600 /swapfile
mkswap /swapfile && swapon /swapfile

fallocate does not work on every filesystem (btrfs), where dd is needed. And cloud system disks often have poor IOPS, so swap thrashing slows the whole host. Persistent non-zero si/so means you need more memory, not more swap.