Turn a spare partition into usable swap in minutes and avoid out-of-memory troubles. 16.11.2025 | reading time: 2 min When a Linux box runs out of RAM processes stall or OOM killer appears; enabling a swap partition is a fast way to give the system breathing room by adding disk-backed virtual memory. Turn a partition into swap Do this on a test system first, then run the commands below to convert an existing partition into swap and enable it immediately: ``` # list block devices sudo lsblk -f # format the partition as swap sudo mkswap /dev/sdb1 # enable swap right away sudo swapon /dev/sdb1 # verify memory and swap free -h # find UUID to make the change persistent sudo blkid /dev/sdb1 # example output: /dev/sdb1: UUID=0123-ABCD TYPE=swap # append fstab entry (use the UUID you found) echo 'UUID=0123-ABCD none swap sw 0 0' | sudo tee -a /etc/fstab # confirm the active swap sudo swapon --show ``` Tuning and caveats Decide between a swap partition and a swapfile: partitions are simple and time-tested while modern kernels support performant swapfiles; remember swap is much slower than RAM so tune "vm.swappiness" with sysctl if you want to influence how eagerly the kernel uses swap, and ensure swap is at least RAM-sized if you rely on hibernation. Check and monitor Monitor swap usage with `swapon --show` and `cat /proc/swaps`, and watch system memory with `free -h` or `top`; for encrypted swap use a LUKS container and open it at boot, and consider compressed RAM approaches like zram for systems where disk-backed swap is undesirable. Next steps After enabling swap, test system behavior under load and adjust swappiness or priorities as needed; continue learning core system administration and consider formal certification such as CompTIA Linux+ or LPIC-1, with bitsandbytes.academy offering intensive exam preparation. Join Bits & Bytes Academy First class LINUX exam preparation. setup filesystem utilities storage