[HowTo] Change swap size in Linux (Ubuntu)
|From Ubuntu 17, the swap partition was replaced by a swap file. The main advantage of the swap file is easy resizing.
In the following example, we will change the swap size from 2 GB to 4 GB.
-
Turn off the swap
sudo swapoff -a
-
Resize the swap
sudo dd if=/dev/zero of=/swapfile bs=1G count=4
if = input file
of = output file
bs = block size count = multiplier of blocks -
Make the file as swap
sudo mkswap /swapfile
-
Activate the swap file
sudo swapon /swapfile
-
Check the amount of swap available
grep SwapTotal /proc/meminfo