Created
February 28, 2021 20:44
-
-
Save kwojc/ae1a6229da8e373ab8ce4a0fc3f2567d to your computer and use it in GitHub Desktop.
Add swap to digitalocean ubuntu droplet in seconds
This file contains hidden or 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/bash | |
| fallocate -l 1G /swapfile | |
| chmod 600 /swapfile | |
| mkswap /swapfile | |
| swapon /swapfile | |
| cp /etc/fstab /etc/fstab.bak | |
| echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab | |
| echo 'vm.swappiness = 10' >> /etc/sysctl.conf | |
| echo 'vm.vfs_cache_pressure = 50' >> /etc/sysctl.conf | |
| reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment