Learn how to disable Linux swap on the fly and why you might need to. 09.05.2026 | reading time: 2 min When memory pressure hits, swap helps — but sometimes an administrator needs to disable swap immediately for testing or maintenance; the `swapoff` command disables swap devices or files so the system uses RAM only. Live demo Try this short demo to see `swapoff` in action: ```$ swapon --show NAME TYPE SIZE USED PRIO /dev/sda2 partition 2G 0B -2 $ sudo swapoff -a $ swapon --show # no output (empty)``` Options and risks `swapoff` accepts device or file names and the common shortcut `-a` or `--all` to disable all swap entries; use `-v` for verbose output, but be careful, because turning off swap under heavy memory load can trigger the OOM killer and kill processes. How to prepare safely Before disabling swap move caches and reduce memory use: stop large services, lower `vm.swappiness` temporarily, check `free -h` and `/proc/swaps`, and update `/etc/fstab` or systemd swap units if you want the change to persist across reboots. Related commands that help Use `swapon --show` or `cat /proc/swaps` to list active swap, `mkswap` to prepare a swap file or partition, and `free -h` to monitor memory while you run `swapoff`. Quick take `swapoff` is a small but powerful tool: it disables swap on the live system so an administrator can perform maintenance or tests without reboot; learn more about Linux system behavior and consider advancing to certifications like CompTIA Linux+ or LPIC-1 with intensive exam preparation at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. storage processes boot-process troubleshooting utilities