Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paintmeyellow/283c8384a84f99c2ab7189cbc3b680da to your computer and use it in GitHub Desktop.
Save paintmeyellow/283c8384a84f99c2ab7189cbc3b680da to your computer and use it in GitHub Desktop.
How to Extend Swap Space using Swap file in Linux
//1. Check the size of existing swap space
free -m
//2.Create a swap file of size 1 GB
sudo fallocate -l 1G /swap_file
//3.Secure the swap file
chmod 600 /swap_file
//4.Enable the Swap Area on Swap File
mkswap /swap_file
//5.Add the swap file entry in fstab file
echo "/swap_file swap swap defaults 0 0" >> /etc/fstab
//6. Extend Swap Space
swapon /swap_file
//Note: To disable the swap file
swapoff /swap_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment