How to add SWAP

What is SWAP?
"Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the physical memory is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.

Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.

The size of your swap space should be equal to twice your computer's RAM, or 32 MB, whichever amount is larger, but no more than 2048 MB (or 2 GB)."


You need more SWAP? You can use this trick, you can create a file with some filesize (no more tan 2GB) and use it to get additional SWAP.

Login as root tou your server using ssh.
# dd if=/dev/zero of=/usr/swap-file bs=1024 count=filezie_you_want
# mkswap /usr/swap-file
# swapon /usr/swap-file
# swapon -s

Edit /etc/fstab:
#nano /etc/fstab
And add this:
/usr/swap-file swap swap defaults 0 0

To check free SWAP use:
# free -m