Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following will create and enable a 8GB swap file at /var/swap.0swapfile

Code Block
languagebash
sudo dd if=/dev/zero of=/var/swap.0swapfile bs=1M count=8120
sudo mkswap /var/swap.0swapfile
sudo chmod 600 /var/swap.0swapfile
sudo swapon /var/swap.0swapfile

Making swap persistent

Doing the above will simply enable swap.  After a server reboot swap won't be enabled.  Do the following to make it persistent:

Code Block
languagebash
sudo cp /etc/fstab /etc/fstab.backup
echo '/var/swap.0swapfile none swap defaults 0 0' | sudo tee -a /etc/fstab

...