Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A simple little shell script that executes the digital ocean swap file tutorial.
# Creates a 1gb swap image.
# @see
if [ -f /var/swap.img ]; then
echo "Swap file already exists."
touch /var/swap.img
chmod 600 /var/swap.img
dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
mkswap /var/swap.img
swapon /var/swap.img
echo "/var/swap.img none swap sw 0 0" >> /etc/fstab
sysctl -w vm.swappiness=30
echo "Swap created and added to /etc/fstab for boot up."

This comment has been minimized.

Copy link
Owner Author

@peterchester peterchester commented Aug 29, 2014


curl -o
sudo /bin/sh
rm -rf

This comment has been minimized.

Copy link

@pesach pesach commented Oct 28, 2016

You may want to add this line not to lose swappiness after reboot:
echo "vm.swappiness=30" >> /etc/sysctl.conf

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.