#
SWAP on Linux
#
enabling SWAP on a Centos 7
count=2048 - size of SWAP in MB's
sudo dd if=/dev/zero of=/swapfile count=2048 bs=1MiB
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Then edit the /etc/fstab
file, and add following line to the end:
/etc/fstab
/swapfile swap swap sw 0 0
#
disabling SWAP file on Centos 7
sudo swapoff -v /swapfile
next, remove the swap file entry /swapfile swap swap defaults 0 0
from
/etc/fstab
file
and, delete the swapfile with rm command
sudo rm /swapfile
#
enabling SWAP on Ubuntu 20
1G - size of swap file
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Backing up /etc/fstab file
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab