Skip to content

Instantly share code, notes, and snippets.

@q7r
Forked from peterchester/swap.sh
Last active December 30, 2016 08:41
Show Gist options
  • Save q7r/136ca7dbbb5f98e17e38 to your computer and use it in GitHub Desktop.
Save q7r/136ca7dbbb5f98e17e38 to your computer and use it in GitHub Desktop.
A simple little shell script that executes the digital ocean swap file tutorial.
#/bin/sh
if [ -f /swapfile ]; then
echo "Swap file already exists."
else
dd if=/dev/zero of=/swapfile bs=1024k count=2000
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
sysctl -w vm.swappiness=20
echo "vm.swappiness=20" >> /etc/sysctl.conf
free
echo "Swap created and added to /etc/fstab for boot up."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment