Pcornel
Linux · Filesystems & Mounting

swap

Cheat sheet · https://pcornel.dk/topic.php?topic=2758

Back to the Topic

Answer

Swap is disk space (a partition or swap file) used when RAM is short; the kernel moves inactive pages there. vm.swappiness controls how eagerly it swaps.

Remember

Heavy swap activity (si/so in vmstat) slows everything — it means too little RAM for the workload. Swap files need chmod 600 and mkswap; add to fstab. Some workloads (Kubernetes nodes) require swap off.

First checks

  • swapon --show — active swap
  • findmnt — mount tree with options
  • df -hT — usage and filesystem types
  • findmnt --verify — check /etc/fstab
  • dmesg -T | grep -iE 'ext4|xfs|btrfs' — filesystem kernel messages

Verify in this order

memory pressure → kernel reclaims pages → anonymous pages written to swap → read back on access

Where it usually breaks

First mismatch in hardware/block device → kernel driver/mapper/RAID/LVM → filesystem → mount namespace/options → path permissions/MAC → consumer I/O; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2758

Confirmation

Confirm action

Continue?