How to increase Swap Size

Linux works Swap Area to back its mechanical memory with an overflow space. In most cases, the recommended amount is a disk area equal to the number of mechanical memory you have placed. You don’t require your policy to ever run out of RAM+swap, but you regularly would rather have sufficient RAM in the policy. So twice the size of RAM doesn’t need to swap.
The free -m command shows that the swap concept in your current server.
We can build 4GB of swap size now.
Create Swap file

touch /swapfile

Use the following command to create 4GB of swap file.

dd if=/dev/zero of=/swapfile bs=1M count=4096

if=/dev/zero : Read from /dev/zero file. /dev/zero is a special file in that provides as many null characters to build storage file called /swapfile.
of=/swapfile1 : Read from /dev/zero write stoage file to /swapfile.
bs=1M : Read and write 1M at a time.
count=4096 : Copy only 4096 input blocks.
This will create a new partition with 4GB space. To make it a swap partition you need to execute the following command.

mkswap /swapfile

Now the swap file is created.

activate /swapfile file swap space now.

swapon /swapfile

Add entry on /etc/fstab file to activate after Linux system reboot.

vi /etc/fstab

/swapfile swap    swap    defaults        0 0

save and close the file.

Now check your swap space now.

free -m

In order to delete swap.

Run “swapoff /swapfile” command

Remove the entry from /etc/fstab file

Remove /swapfile  file (using rm command)

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Stats and Monitoring Process tool

Mysqlmymonlite Stats and Monitoring process free tool, Bash shell script tool used to gather...

cPanel Game Server Installation

cPGS is a software module that allows you to set up and run a game server. You are even able to...

Attracta SEO Tools Installation

Attracta SEO tool will verify that your website has not been flagged by Google as containing...

Server load alerts shell script

Simple Server load alerts shell script to monitor your server load average, Free Memory and Swap...

Powered by WHMCompleteSolution