Ognjen Regoje bio photo

MY NAME IS
Ognjen Regoje
BUT YOU CAN CALL ME OGGY


I make things that run on the web (mostly).
More /ABOUT me.

me@ognjen.io Twitter LinkedIn Instagram Github

Very quickly adding swap to Ubuntu 14.04

Following is the quickest way to add swap space to Ubuntu 14.04 installation. I am writing the post because I keep having to look this up and given the convenience and price of DigitalOcean’s base plan it is necessary for anything a bit heavier.

In fact, it is necessary for anything that would use nginx because the compilation normally fails when the machine does not have more then 1GB of memory. given that nginx normally chokes while compiling if the machine does not have more then 1GB.

sudo fallocate -l 8G /swapfile          # Create swap file.
                                        # Normally for smaller machines RAM x 2.

sudo chmod 600 /swapfile                # Change the permission of the swap file.

mkswap /swapfile                        # Needed for later versions

sudo swapon /swapfile                   # Turn the swap file on.

sudo nano /etc/fstab                    # Open fstab for editing to persist the changes.
/swapfile   none    swap    sw    0   0 # Paste this at the end of the file

Credit where credit is due.

#linux #technical