SWAP is virtual memory outside of installed physical memory (RAM).
Check the system to see if SWAP information already exists:
free -h
sudo swapon --show
Check free space on the partition:
df -h
Create a SWAP file:
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
SWAP file permission check:
ls -lh /swapfile
Enable SWAP space:
sudo mkswap /swapfile
sudo swapon /swapfile
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Optimizing SWAP settings:
sudo nano /etc/sysctl.conf
Add to the bottom of the file vm.swappiness=10
and vm.vfs_cache_pressure=50
.