sudo swapon -s
sudo swapoff -a
Assuming you wish to increase swap space to 8GB, use the following command, or replace the 8G
with the amount of space you'd like to allocate. Note: You need to have at least this much free space on your storage device.
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon -s
sudo nano /etc/fstab
Add the following line to the file, save the file, and exit:
/swapfile none swap sw 0 0