Created
June 30, 2016 16:58
-
-
Save nearbycoder/e0f7f8f7306b83f646fe5159f6afd7b6 to your computer and use it in GitHub Desktop.
Delete Swap from Digital Ocean VM
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
#!/bin/sh | |
# does the swap file exist? | |
grep -q "swapfile" /etc/fstab | |
# if it does then remove it | |
if [ $? -eq 0 ]; then | |
echo 'swapfile found. Removing swapfile.' | |
sed -i '/swapfile/d' /etc/fstab | |
echo "3" > /proc/sys/vm/drop_caches | |
swapoff -a | |
rm -f /swapfile | |
else | |
echo 'No swapfile found. No changes made.' | |
fi | |
# output results to terminal | |
cat /proc/swaps | |
cat /proc/meminfo | grep Swap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment