How to increase RAM memory (SWAP).

Many time we face the issue with the server performance because of RAM memory, the RAM memory usage is very high but we can’t increase the RAM memory because of any reason like , client won’t have enough finance to increase the RAM on his server or server chassis not having slot to attache the additional RAM memory in that case we can increase the swap memory by using the following simple steps.

1) Check the swap partition by using the fdisk -l command.

For example swap partition is /dev/sda5

2nd) To enable the /swap partition

swapon /dev/sda5

3rd)To enable the swap at boot time, edit the /etc/fstab and add the following line:

/dev/sda5 swap swap defaults 0 0

Now we can change the swap value by creating the swapfile for swap memory.

To create the swapfile use the following command

dd if=/dev/zero of=/swapfile bs=1024 count=3145428

In above example, we have created the RAM swapfile with the 3G, change the value in “count” as per your requirement.

4th) Now make the swapfile as a swap

mkswap /swapfile

Run the following command to enable the swap

swapon /swapfile

For permanent swapfile swap memory add the entry in /etc/fstab, so that /swapfile will mount every time when server rebooted else you have mount it manually after every reboot.

/swapfile swap swap defaults 0 0

Verify the new RAM SWAP memory by using the following command.

cat /proc/swaps

or

free -m

If  your server having LVM based partition then refer to the following tutorial to increase the RAM swap memory on LVM based server.

About Anant 386 Articles
Senior technical writer