Skip to content

Instantly share code, notes, and snippets.

@porimol
Forked from cobyism/digital-ocean-swap.sh
Created June 12, 2016 19:28
Show Gist options
  • Save porimol/c1078440704b91bd0a4e9ac4655b6a55 to your computer and use it in GitHub Desktop.
Save porimol/c1078440704b91bd0a4e9ac4655b6a55 to your computer and use it in GitHub Desktop.
Commands to create swapfile on a Digital Ocean Ubuntu droplet
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
swapon -s
free -m
@porimol
Copy link
Author

porimol commented Aug 21, 2016

Make the Swap File Permanent

We have our swap file enabled, but when we reboot, the server will not automatically enable the file. We can change that though by modifying the fstab file.

Edit the file with root privileges in your text editor :
sudo nano /etc/fstab

At the bottom of the file, you need to add a line that will tell the operating system to automatically use the file you created :
/swapfile none swap sw 0 0

For more information : Article Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment