Created
November 11, 2011 18:08
-
-
Save oparrish2/1358720 to your computer and use it in GitHub Desktop.
Script for creating a filesystem swap file on Linux
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 | |
SWAP_SIZE_MEGABYTES=$1 | |
if [ $SWAP_SIZE_MEGABYTES -eq 0 ];then | |
echo No swap size given, skipping. | |
else | |
if [ -e /swapfile ];then | |
echo /swapfile already exists, skiping. | |
else | |
echo Creating /swapfile of $SWAP_SIZE_MEGABYTES Megabytes | |
dd if=/dev/zero of=/swapfile bs=1024 count=$(($SWAP_SIZE_MEGABYTES*1024)) | |
mkswap /swapfile | |
swapon /swapfile | |
echo Swap Status: | |
swapon -s | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment