Created
March 20, 2012 04:56
-
-
Save bertrandom/2131510 to your computer and use it in GitHub Desktop.
Creates a 4 gig swap file and mounts it as swap space, used for EC2 small instances for on-boot ephemeral swap space, put it somewhere in boot init
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/bash | |
if swapon -s | grep -q /mnt/swapfile | |
then | |
echo "Swapfile already mounted" | |
else | |
if [ -e /mnt/swapfile ] | |
then | |
echo "Mounting swapfile" | |
swapon /mnt/swapfile | |
else | |
echo "Creating swapfile" | |
dd if=/dev/zero of=/mnt/swapfile bs=1M count=4096 | |
mkswap /mnt/swapfile | |
swapon /mnt/swapfile | |
fi | |
fi |
Author
bertrandom
commented
Mar 20, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment