How To Increase Swap Space On Linux Print

  • 0

Occasionally, the default physical memory is insufficient to complete particular tasks or processes. It's possible that processes are transferring more memory into and out of swap space. This article will show you how to increase swap memory on a Linux machine.

 

Step 1

 

Create a swap file on the current File system, for example, root; a new Directory can be created for this purpose.

sudo mkdir /swap

 

Step 2

Make a new file in this new directory; in this case, a 2GB file is created.

sudo dd if=/dev/zero of=/swap/swapfile1 bs=1M count=2048

 

Step 3

 

On the newly formed file, establish a new swap area.

sudo mkswap  /swap/swapfile1

 

Step 4

 

Modify the file's permissions.

sudo chmod 600 /swap/swapfile1

 

Step 5

 

In this step, add the swap partition to the /etc/fstab file as follows:

/swap/swapfile1    swap   swap      defaults       0 0

 

Step 6

 

Load the new swap space for the Instance that was created.

sudo swapon -a

 

Step 7

 

Run the command below to see a list of swap devices.


sudo swapon -s

 

This command will show you the new swap area that the instance will have accessible.

sudo free -m

 

 


Was this answer helpful?

« Back

Powered by WHMCompleteSolution