Created
March 2, 2017 13:34
-
-
Save arianacosta/c5a10f3a83084c7ed0d72c015e2fb19d to your computer and use it in GitHub Desktop.
Bash Script to Resize Swap File in Linux
This file contains hidden or 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
#!/bin/bash | |
echo "====== Current Swap ======" | |
sudo swapon -s | |
echo "====== Turning Off Swap ======" | |
sudo swapoff /swapfile | |
echo "====== Allocating 4GB Swap ======" | |
sudo fallocate -l 4G /swapfile | |
echo "====== Making Swap ======" | |
sudo mkswap /swapfile | |
echo "====== Setting Permissions to Root Only ======" | |
sudo chmod 600 /swapfile | |
echo "====== Turning On Swap ======" | |
sudo swapon /swapfile | |
echo "====== Current Swap ======" | |
sudo swapon -s | |
echo "====== Done! ======" | |
echo $(date) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment