# check cuurent swap space
sudo swapon --show
free -h

# check available disk space
df -h

# create swap file
sudo fallocate -l 1G /swapfile

# verification
ls -lh /swapfile

# enable swap file
sudo chmod 600 /swapfile
ls -lh /swapfile

# mark file as swap space
sudo mkswap /swapfile
sudo swapon /swapfile

# verification
sudo swapon --show
free -h

# make swap file permanent
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

# adjust swappiness
cat /proc/sys/vm/swappiness
sudo sysctl vm.swappiness=10

# set to automatically restart
sudo nano /etc/sysctl.conf
vm.swappiness=10

# set cache pressure
cat /proc/sys/vm/vfs_cache_pressure
sudo sysctl vm.vfs_cache_pressure=50

# make permanent
sudo nano /etc/sysctl.conf