Last active
August 29, 2015 14:07
-
-
Save mrhyde/41902a8f43ebb1bbee68 to your computer and use it in GitHub Desktop.
Create swap file on digitalocean ubuntu droplets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
# Creates a 4Gb swap image on your Droplet | |
# @see https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04 | |
if [ -f /swapfile ]; then | |
echo "Swap file already exists." | |
else | |
sudo fallocate -l 4G /swapfile | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
echo "/swapfile none swap sw 0 0" >> /etc/fstab | |
echo "vm.swappiness=30" >> /etc/sysctl.conf | |
echo "vm.vfs_cache_pressure=50" >> /etc/sysctl.conf | |
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