Increase Swap Partition Space in Linux



Sometimes it is necessary to add more swap space after installation. For example, you may upgrade the amount of RAM in your server from 1GB to 2 GB, but there is only 2GB of swap space. It might be advantageous to increase the amount of swap space to 3GB or 4GB if you perform memory-intense operations or run applications that require a large amount of memory.
We can do it in two ways: 
  1. add a swap partition 
  2. add a swap file.
It is recommended that you add a swap partition, but sometimes that is not easy if you do not have any free space available.
Create a new partition or Logical volume, based on your environment

For example

lvcreate -L 2GB -n swap_lv appvg

Now make that partition or LV as swap space.
mkswap /dev/appvg/swap_lv

Now turn on the swap on that LV or partition.

swapon /dev/appvg/swap_lv

Now this partition is added as swap space.

To check,

free -m
cat /etc/swaps


To enable it at boot time, edit /etc/fstab to include: 


/dev/appvg/swap_lv      swap swap defaults 0 0



For Creating the swap file and add it to swap space, see my earlier post here


Please don't forget to post your comments on this..

Share this

Related Posts

Previous
Next Post »

1 comments:

Write comments
Anonymous
March 31, 2019 at 4:05 PM delete

Hi my friend! I want to say that this post is awesome, great written and come with almost all vital infos.
I'd like to peer extra posts like this .

Reply
avatar

What do you think about this Article? Add your Opinion..! EmoticonEmoticon