sudo swapoff -a
sudo dd if=/dev/zero of=/swapfile bs=1G count=8
or
sudo dd if=/dev/zero of=/swapfile bs=512M count=16
sudo chmod 0600 /swapfile
sudo mkswap /swapfile
# Set up a Linux swap area
sudo swapon /swapfile
# Turn the swap on
Check if it worked
grep Swap /proc/meminfo
Make it permanent (persist on restarts) Add this line to the end of your /etc/fstab:
/swapfile swap swap sw 0 0