A quick guide to creating and enabling a swap file.
sudo swapoff /swapfile
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -h
echo '/swapfile none swap defaults 0 0' | sudo tee -a /etc/fstab
After rebooting, run free -h again to verify
that your swap file is active.