Created
April 26, 2022 18:03
-
-
Save paintmeyellow/283c8384a84f99c2ab7189cbc3b680da to your computer and use it in GitHub Desktop.
How to Extend Swap Space using Swap file in Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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