SWAP File

If you have rented a weak server, this is the solution for you. It will not be superfluous to play it safe and increase the operational capabilities of the server. Text instructions are herearrow-up-right.

If there is a possibility that you have ALREADY created a SWAP file, you need to check its existence.

sudo swapon --show

If the file does not exist, then proceed to create it.

sudo apt install fallocate -y
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

To make the change permanent, open and modify the fstab file:

sudo nano /etc/fstab

Let's insert the following line at the end of the file: /swapfile swap swap defaults 0 0

🎉Make sure the file is created and running:

sudo swapon --show
sudo free -h

Last updated