sudo swapoff /swapfile
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -h
Add this line to /etc/fstab to enable swap at boot
/swapfile none swap defaults 0 0
After that, reboot the system and check with free -h. You should see the swap size you created appear.