Back To Blog Posts
Adding Swap Space on Ubuntu 14.04
Recently, I ran into the following error while installing some software on Ubuntu 14.04:
virtual memory exhausted: Cannot allocate memory
Not good - but the fix is easy – add some swap space to your instance. The following is a list of commands you can use to successfully resolve this problem:
Now add the following like to /etc/fstab
:
/swapfile none swap sw 0 0
And do not forgot to reboot …..
How lets make sure the swap space exists:
As you can see, you now have 3GB of swap space on your device !!! Not - EC2 comes with ZERO swap
space by default - so it might be no a surprise if you are seeing this issue - especially on a t2.micro
instance.