Create a Swap File
sudo fallocate -l 1G /swapfile
ls -lh /swapfile
Output:
-rw-r--r-- 1 root root 1.0G Apr 25 11:14 /swapfile
Enabling the Swap File
sudo chmod 600 /swapfile
ls -lh /swapfile
Output:
-rw------- 1 root root 1.0G Apr 25 11:14 /swapfile
sudo mkswap /swapfile
Output:
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes) no label, UUID=6e965805-2ab9-450f-aed6-577e74089dbf
sudo swapon /swapfile
sudo swapon --show
Output
NAME TYPE SIZE USED PRIO /swapfile file 1024M 0B -1
echo /swapfile none swap defaults 0 0 >> /etc/fstab