Swap not enabled despite configuration — no swap active
swapon --show returns empty
Focused incident mode — strips away everything but this runbook.
Symptoms
- swapon --show returns empty
- free -h shows 0B swap
- System OOM kills under memory pressure despite having a swapfile configured
Evidence to grab
Collect these artifacts before you change anything — they prove (or rule out) each cause.
Active swap
swapon --showfstab swap entries
grep swap /etc/fstab
Diagnostic flow
Run the steps in order, marking each claim confirmed or refuted. The evidence you gather feeds the ranked causes below.
Guided decision tree is ready.
Steps with commands, expected output, and pass/fail branches.
Ranked root causes
Evidence checklist
- swapon --show is empty
- ls shows the swapfile exists but file does not show 'swap'
Confirm before fixing
file /swapfile 2>/dev/nullCheck if the file is a valid swap area
Fix
dd if=/dev/zero of=/swapfile bs=1M count=1024 && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfileCreate, format, and enable a 1GB swap file
Resolution runbook
Apply from top to bottom after the cause is confirmed. Review every command before running it — risk tags are shown on each.
swapon --showConfirm no swap is active
grep swap /etc/fstabCheck fstab for swap configuration
dd if=/dev/zero of=/swapfile bs=1M count=1024 && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfileCreate and enable a swap file
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstabAdd swap entry to fstab for persistence across reboots
Prevention
- Always add swap during initial server provisioning, not after a memory crisis.
- Set swappiness to 10-60 based on workload type (database vs general).
- Monitor swap usage and alert on sudden increases.
- Use fallocate or dd to create swapfiles; verify with swapon --show after boot.
Related runbooks
Same stack, same failure family — worth a skim.
System is sluggish and unresponsive under load
dmesg shows Out of memory: Killed process <PID>
Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.