Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create swapfile if not already present
#!/bin/bash
# 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.
else
if [ -e /swapfile ];then
echo /swapfile already exists, skipping.
else
echo Creating /swapfile of $SWAP_SIZE_MEGABYTES MB
dd if=/dev/zero of=/swapfile bs=1024 count=$(($SWAP_SIZE_MEGABYTES*1024))
mkswap /swapfile
fi
swapon /swapfile
echo Swap Status:
swapon -s
fi
@kimlindholm

This comment has been minimized.

Copy link
Owner Author

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.