Skip to content

Latest commit

 

History

History
52 lines (33 loc) · 843 Bytes

create-a-swap-file.md

File metadata and controls

52 lines (33 loc) · 843 Bytes

Create a swap file

Common problem on small DO or similar instances is that one runs out of memory pretty quick, to negate this it's possible to add a swap file. Although it's not recommended on machines that use ssd.

To create a swap file of 1Gb run:

sudo fallocate -l 1G /swapfile

Make it readable only to root:

sudo chmod 600 /swapfile

Make it swap file:

sudo mkswap /swapfile

And enable it running:

sudo swapon /swapfile

Check that it worked:

sudo swapon -s

Now it's time to make swap file permanent, by editing fstab:

sudo vi /etc/fstab

and adding this line:

/swapfile none swap sw 0 0

Voila!


More info in this article: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04