Adding swap space on Ubuntu 18.04
If you are running low on RAM on your system, you might want to consider adding some swap space. The following will allocate and assign a 2GB swap space.
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
It is possible to assign a second swap space. Just repeat the above commands but replace /swapfile
with another name, eg. swapfile2
Removing swap space
sudo swapoff /swapfile
sudo rm /swapfile
To make permanent
Add the following line to /etc/fstab
/swapfile swap swap defaults 0 0