Reading time: 1 minutes.
Why do you need a swap partition?
There are a variety of reasons you may need a swap partition. However, the main reason will most likely be that you do not have enough RAM to process some tasks that you want to do. To help mitigate this, you can increase the swap space available to your system.
The following are the steps to increase swap file size:
First, find the location of the current swapfile.
sudo swapon -s
Next, deactivate the swap file using the file found from above.
sudo swapoff /swapfile
Next, create the swapfile with the desired size:
sudo fallocate -l 64G /swapfile
You can confirm the allocated size with:
ls -lh /swapfile
Set the correct file permissions
sudo chmod 600 /swapfile
Then mark the file as swap space:
sudo mkswap /swapfile
Then re-enable the swapfile:
sudo swapon /swapfile
Finally, insert the following entry into fstab to enable the swap space on boot:
/swapfile none swap sw 0 0