Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create swapfile if not already present
# Create swapfile if not already present. Default size is 2 GB.
if [ ${SWAP_SIZE_MEGABYTES:=2048} -eq 0 ];then
echo No swap size given, skipping.
if [ -e /swapfile ];then
echo /swapfile already exists, skipping.
echo Creating /swapfile of $SWAP_SIZE_MEGABYTES MB
dd if=/dev/zero of=/swapfile bs=1024 count=$(($SWAP_SIZE_MEGABYTES*1024))
mkswap /swapfile
swapon /swapfile
echo Swap Status:
swapon -s

This comment has been minimized.

Copy link
Owner Author

kimlindholm commented Feb 19, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.