Changing the SWAP file size in Ubuntu 18.045

If you install linux without a dedicated swap partition you will get a swap file. The swap file is in root:
/swapfile

To see the size you can run
swapon --show

You can turn off swap with
sudo swapoff /swapfile

If you run `free -h` you will see that you have 0 swap

Now you can allocate more space to that swapfile
sudo fallocate -l 20G /swapfile

Now make that file a swap again
sudo mkswap /swapfile

And now turn on swap again
sudo swapon /swapfile

Comments