Search This Blog

Tuesday, December 25, 2012

How to resize or shrink the partition (LVM) in linux or VM

I wanted to shrink LVM partition in VM which has redhat linux and expand root partition because of  memory issue on root partition.  I have done searching excercise in the web and below are the results of the search and best pages that I have seen. However I was not able to reduce the LVM partition as all the procedures mentioned in the below did not recognize the LVM partition created in the redhat linux VM installation. Below procedures are pretty good in general and but does not work for LVM on VM. gparted, parted or steps mentioned below may work other partions. You can try got LVM, it may work for you. I have kept consolidated search result in one page.

Back up all your important data before attempting this. Always assume that you can lose all your data when resizing partitions.

Shrink LVM without dataloss

This forum thread suggests the following procedure, in this example we shrink a partition from 10G to 9G:
First, we unmount.
# umount /dev/vg_blah/lv_blah
Check the file system.
# e2fsck -f /dev/vg_blah/lv_blah
Resize the file system.
# resize2fs /dev/vg_blah/lv_blah 9G
Reduce the size of the logical volume.
# lvreduce -L -1G /dev/vg_blah/lv_blah
Shrink the volume group if desired.
# vgreduce vg_blah /dev/sdxy

No comments:

Post a Comment