Extend or Increase swap memory size in Linux

To increase the swap size fire the following commands. First, to create 4,000 MB of swap space:

$ sudo dd if=/dev/zero of=/swapspace bs=1M count=4000 

OR

$ sudo fallocate -l 4000M /swapspace 

Next turn it into a usable swap file:

$ sudo mkswap /swapspace

Activate it:

$ sudo swapon /swapspace

Confirm active swap spaces:

$ cat /proc/swaps

Next, add the following line to /etc/fstab to activate the new swap at boot:

/swapspace none swap defaults 0 0

See also this wiki page: https://help.ubuntu.com/community/SwapFaq

You can check the alternative ways of doing the same thing here.

Running low on budget? Get the best Shared hosting at an Affordable Rate!