This sets up SWAP on an existing Linux System
Create the file that will be used.
sudo fallocate -l 1G /swapfile
If the command failed you can use the following
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
Only allow root to use it
sudo chmod 600 /swapfile
Use mkswap to set up the swap area
sudo mkswap /swapfile
Activate the swap
sudo swapon /swapfile
Make the change permanent in /etc/fstab
/swapfile swap swap defaults 0 0
Confirm the changes
sudo swapon --show