Skip to content

Instantly share code, notes, and snippets.

@arianacosta
Created March 2, 2017 13:34
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 arianacosta/c5a10f3a83084c7ed0d72c015e2fb19d to your computer and use it in GitHub Desktop.
Save arianacosta/c5a10f3a83084c7ed0d72c015e2fb19d to your computer and use it in GitHub Desktop.
Bash Script to Resize Swap File in Linux
#!/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