Sharing Knowledge | System Admin Articles

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..



Labels: Linux, Quick HOWTO

My Profile PhotoAbout the Author

I'm Parthiban, An UNIX System Admin by Profession. I'm Experienced in Linux/Unix System Administration and Scripting. I have done lot of work on the infrastructure Mgmt side in Linux, UNIX and Windows system administration, Hardware, Storage and Data center. I'm blogging since 2008.
Follow Me On Twitter or On Facebook

0 Comments for "Increase Swap Partition Space in Linux"

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

Back To Top