Safely re-enable swap on Linux systems to restore memory breathing room without breaking hibernation or security. 25.01.2026 | reading time: 3 min When memory pressure returns, re-enabling swap can stop processes from being killed, but done carelessly it can break hibernation or leak sensitive data; this short guide shows concrete, command-line steps to restore swap safely and persistently. Swapfile restoration Scenario: a test server had swap disabled for benchmarking and must be returned to production; create and enable a 2 GiB swapfile with: ```sudo fallocate -l 2G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile``` Verify with: ```swapon --show``` Example output: ```NAME TYPE SIZE USED PRIO /swapfile file 2G 0B -2``` Persist across reboot by adding to fstab: ```/swapfile none swap sw 0 0``` and if hibernation is required obtain the swap UUID with ```blkid /swapfile``` and update the initramfs so resume works. Caveats and tuning Use `fallocate` when supported because it is fast, but fall back to `dd` if the filesystem lacks fallocate; always set permissions to 600 and run `mkswap` before `swapon`; encrypted swap needs a mapped device and correct fstab entry, and hibernation requires the swap UUID in the kernel resume parameter plus regenerating the initramfs with the distribution tool; tune swappiness via `sysctl vm.swappiness` to influence how eagerly the kernel uses swap. Commands and situations to remember Turn off swap safely with `sudo swapoff -a` before removing or shrinking swap; check memory with `free -h` and `vmstat`; use `blkid` to discover UUIDs and `mount` or `cat /proc/swaps` to inspect active swap; consider zram or swap on fast NVMe for high-performance needs but weigh write amplification and wear. Next steps Re-enabling swap is simple, but the surrounding choices matter for security, hibernation and performance; practice the steps on a nonproduction host, then document the fstab and resume settings so an administrator can reproduce them reliably; to deepen system knowledge consider formal training and exam preparation such as CompTIA Linux+ or LPIC-1 with intensive courses at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. setup filesystem utilities storage processes troubleshooting