Linux Swapfile
Creating the swapfile
Section titled “Creating the swapfile”sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progressThis creates a swapfile and allocates 4GB for it
Set the required permissions
Section titled “Set the required permissions”sudo chmod 600 /swapfileEnable the swapfile
Section titled “Enable the swapfile”sudo mkswap /swapfilesudo swapon /swapfileEnsure swap is enabled at boot
Section titled “Ensure swap is enabled at boot”sudo bash -c "echo /swapfile none swap defaults 0 0 >> /etc/fstab"Increasing the size of the swapfile
Section titled “Increasing the size of the swapfile”Turn off all swap processes
Section titled “Turn off all swap processes”sudo swapoff -aResize swap
Section titled “Resize swap”Normaly you want your swap to be RAM(GB) + 2GB
So if you have 8GB of ram your swap should be 10GB
sudo dd if=/dev/zero of=/swapfile bs=1G count=10Make the file usable as swap
Section titled “Make the file usable as swap”sudo mkswap /swapfileActivate the swapfile
Section titled “Activate the swapfile”sudo swapon /swapfileThis should be it!