====== Linux - Create Swap File ====== ===== Short ===== fallocate -l 1G /swapfile chmod 0600 /swapfile mkswap /swapfile swapon /swapfile vim /etc/fstab /swapfile none swap sw 0 0 ===== Long ===== Create File (eg. size 1GB). root@server:~# fallocate -l 1G /swapfile Set permissions. root@server:~# chmod 0600 /swapfile Set up swap space. root@server:~# mkswap /swapfile Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes) no label, UUID=2903a264-5dc1-484c-8e1d-b0b6f687e65a Activate Swap space. root@server:~# swapon /swapfile Edit fstab root@server:~# vim /etc/fstab add: /swapfile none swap sw 0 0 ===== Show Status ===== swapon --summary Example. root@server:~# swapon --summary Filename Type Size Used Priority /swapfile file 3145724 346156 -2