Home > Storage > How to resize/shrink lvm home/root partition/filesystem dynamically

How to resize/shrink lvm home/root partition/filesystem dynamically

June 8th, 2011

When you’re trying to extend root file system under lvm environment, here are the steps:

1.Extend the root volume:

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




Categories: Storage Tags:
  1. February 27th, 2012 at 11:55 | #1

    What can i say – i was so close many times but these steps are perfect. Cheers

    • doxerorg
      February 28th, 2012 at 00:21 | #2

      good luck

  1. No trackbacks yet.