PDA

View Full Version : [all variants] LVM Reduce Simply



meggawhat
December 17th, 2009, 07:13 PM
Shrink a Logical Volume

In the code below, replace volgroup and logicalvol with the volume group and logical volume names on your machine. lvmdisk scan will tell you what the names are, and how many GB are there. resize your filesize to match the physical drive GB you want to move the actual data to. Then you can move the data off the drives with pvmove and un-LVM them with vgreduce.

Then you can drop in those 2 new TB drives and reverse the process.

To shrink a LV first

umount the LVM, if the LVM is mounted as /home, log on as root after a
fresh reboot and
umount /home

scan
lvmdiskscan

check
e2fsck -f /dev/volgroup/logicalvol

resize the file system to the desired size
resize2fs /dev/volgroup/logicalvol 400G

reduce the LV by the desired size
lvreduce -L -750G /dev/volgroup/logicalvol

move the data off the drives you want to remove
pvmove -v -/dev/mda7

remove a physical volume from the volume group in this case 'md7' a raid drive
vgreduce volgroup /dev/md7