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
Edit /etc/fstab and add the following line
/swapfile none swap defaults 0 0
After rebooting, run free -h again to verify
that your swap file is active.