Skip to content

Instantly share code, notes, and snippets.

@dafonso
Created February 2, 2019 10:02
Show Gist options
  • Save dafonso/fb053dfcd63bc99434eb6c67666a5312 to your computer and use it in GitHub Desktop.
Save dafonso/fb053dfcd63bc99434eb6c67666a5312 to your computer and use it in GitHub Desktop.
Add swap to a Digital Ocean droplet
rm -f /swapfile
# create swap file - adjust swapfile size to droplet memory
fallocate -l 1024M /swapfile
# make it swap
mkswap /swapfile
# chmod it accordingly
chmod 600 /swapfile
# enable swap
swapon /swapfile
# add it to fstab to be mounted on reboot
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment