Created
April 29, 2021 23:59
-
-
Save sgnl/71f538458085b79cd3c65685ac5b1cec to your computer and use it in GitHub Desktop.
Ubuntu Check for Swapfile or Create it (4096 default)
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 | |
swapon_results=$(swapon -s) | |
if [[ $swapon_results != 0]]; then | |
dd if=/dev/zero of=/swapfile count=4096 bs=1M | |
chmod 600 /swapfile | |
mkswap /swapfile | |
swapon /swapfile | |
echo "/swapfile none swap sw 0 0" >> /etc/fstab | |
else | |
echo "Swap file found. Nothing to do :E" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment