Skip to content

Instantly share code, notes, and snippets.

@steinnes
Created March 15, 2016 02:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steinnes/3a1de7250de10687ade1 to your computer and use it in GitHub Desktop.
Save steinnes/3a1de7250de10687ade1 to your computer and use it in GitHub Desktop.
swapfile setup script
#!/bin/bash
SWAPFILE=/var/swapfile
SWAP_MEGABYTES=2048
if [ -f $SWAPFILE ]; then
echo "Swapfile $SWAPFILE found, assuming already setup"
exit;
fi
/bin/dd if=/dev/zero of=$SWAPFILE bs=1M count=$SWAP_MEGABYTES
/bin/chmod 600 $SWAPFILE
/sbin/mkswap $SWAPFILE
/sbin/swapon $SWAPFILE
@SimonVillage
Copy link

What if is the server restarts? Do we need to modify the /etc/fstab file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment