Recent releases of Ubuntu use swap file instead of the traditional swap partition.
IMPORTANT:
swapon --show
returns:
NAME TYPE SIZE USED PRIO /swapfile file 4G 2.1G -2
NOTE: This shows that there is a swapfile.
Before resizing the swap file, turn the swap off.
sudo swapoff /swapfile
NOTE: The command does not produce any output and it may take a few minutes to complete.
Make sure that there is enough free RAM available to take the data from swap file.
sudo fallocate -l 4G /swapfile
sudo mkswap /swapfile
NOTE: There should be some output where it warns you that the old swap signature is being wiped.
sudo swapon /swapfile
NOTE: All done!
swapon --show
free -h
returns:
total used free shared buff/cache available Mem: 62Gi 10Gi 886Mi 364Mi 50Gi 50Gi Swap: 4.0Gi 2.1Gi 1.9Gi