add swap space ubuntu

I increased/add the swap size to 8 GB with the following sequence ( If you look at your system monitor swap space you will see Ubuntu emptying out your swap space as you run the first command):

sudo swapoff /swapfile
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Verify it:

 sudo swapon --show
 free -m

Make it permanent:

echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Leave a Reply