Learn to create and manage swap files and partitions from the shell to control memory pressure and system behavior. 15.11.2025 | reading time: 2 min Swap extends RAM by using disk space; this guide shows how to create a swap file, enable it, and make it persistent so the system can use extra memory when needed. Hands-on example Follow these commands to add a 1G swap file and verify it in one session. ```bash sudo fallocate -l 1G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile Setting up swapspace version 1, size = 1 GiB (1073741824 bytes) no label, UUID=11111111-2222-3333-4444-555555555555 sudo swapon /swapfile sudo swapon --show NAME TYPE SIZE USED PRIO /swapfile file 1024M 0B -2 ``` What to watch next Decide between a swap partition and a swap file, set permissions to 600 to protect data, and pick a priority with `swapon -p` if multiple swap areas exist; tune kernel behavior with `vm.swappiness` and use `blkid` to reference UUIDs in `/etc/fstab` for stable mounting across reboots. Related command-line helpers Core commands are `mkswap`, `swapon`, and `swapoff`, but tools like `fallocate` or `dd` create files, `blkid` finds UUIDs, `systemctl` or the `/etc/fstab` entry make swap persistent, and `zramctl` provides compressed in-RAM swap alternatives for embedded or SSD-sensitive systems. Make it permanent Persist the file by adding an `/etc/fstab` line such as `/swapfile none swap sw 0 0` or reference the swap UUID to avoid device-name shifts; test by rebooting and confirming `swapon --show` so the change survives boot. Final thought Manual swap configuration is a small, powerful skill that helps control memory pressure and performance; practice these steps and consider deeper study for certification, such as CompTIA Linux+ or LPIC-1, with intensive exam preparation at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. setup filesystem storage boot-process troubleshooting