Increase or Decrease LV Swap in CentOS 6/RHEL 6

Scenario: How to increase or decrease swap space(logical volume swap) in CentOS 6/RHEL 6

System: CentOS 6/ RHEL 6

Steps increase Swap space
Example increase 1 GB swap space.

1) You must check the path of swap logical volume and the free space in the swap volume group before continue to step 2.
# free -m
# lvdisplay | grep swap
# vgs

2) From step 1 we got swap space is 3GB, the swap path and free size of the swap Volume Group,then continue disable swapping for the associated logical volume:
# swapoff -v /dev/vg_kucing/lv_swap

3) Resize the LVM2 logical volume by 2 GB:
# lvresize /dev/vg_kucing/lv_swap -L +1G

4) Format the new swap space:
# mkswap -f /dev/vg_kucing/lv_swap

5) Enable the extended logical volume:
# swapon -v /dev/vg_kucing/lv_swap

Steps to decrease Swap space
Example decrease 1 GB swap space.

1) Check the path of swap logical volume.
# lvdisplay | grep swap

2) Disable swapping for the associated logical volume:
# swapoff -v /dev/vg_kucing/lv_swap

3) Reduce the LVM2 logical volume by 512 MB:
# lvreduce -L 1G /dev/vg_kucing/lv_swap

4) Format the new swap space:
# mkswap -f /dev/vg_kucing/lv_swap

5) Enable the extended logical volume:
# swapon -v /dev/vg_kucing/lv_swap


Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *