Skip to content

Instantly share code, notes, and snippets.

@yoimbert
Last active August 29, 2015 14:22
Show Gist options
  • Save yoimbert/b605c065968cfc2511de to your computer and use it in GitHub Desktop.
Save yoimbert/b605c065968cfc2511de to your computer and use it in GitHub Desktop.
Swap On EC2
You can add a 1 GB swap to your instance with these commands:
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
sudo mkswap /swapfile
sudo swapon /swapfile
To enable it by default after reboot, add this line to /etc/fstab:
/swapfile swap swap defaults 0 0
On DIGITALOCEAN
sudo dd if=/dev/zero of=/swap bs=1024 count=2097152
sudo mkswap /swap && sudo chown root. /swap && sudo chmod 0600 /swap && sudo swapon /swap
sudo sh -c "echo /swap swap swap defaults 0 0 >> /etc/fstab"
sudo sh -c "echo vm.swappiness = 0 >> /etc/sysctl.conf && sysctl -p"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment