How to resize/shrink lvm home/root partition/filesystem dynamically
When you’re trying to extend root file system under lvm environment, here are the steps:
#lvextend -L500G /dev/VolGroup00/apps-yourapp
2.Grow file system:
#resize2fs /dev/VolGroup00/apps-yourapp 500G
Shrinking can’t be done that easily and requires an umount. To shrink the FS, do the following:
umount <logical-volume-device>
e2fsck -f <logical-volume-device>
resize2fs <logical-volume-device> <new-size-minus-50MB>
lvreduce -L <new-size> <logical-volume-device>
This procedure is for normal(not root) file systems. But what should we do when we want to shrink root/home partition/file system?
You need go to linux rescue mode using a bootable device(Such as the first cd of your linux distro), type linux rescue, and when there jumps out an alert says whether to mount system to /mnt/sysimage, select skip.
When you’re in the shell of rescue mode, do the following steps:
1.lvm vgchange -a y
2.e2fsck -f /dev/VolGroup00/LogVol00
3.resize2fs -f /dev/VolGroup00/LogVol00 500G
4.lvm lvreduce -L500G /dev/VolGroup00/LogVol00
Then reboot your system, and after it starts up, running df -h to check the result. And using vgs to see VSize and VFree.
Enjoy.
