All pastes #968271 Raw Edit

Untitled

public text v1 · immutable
·published 2008-04-02 22:38 UTC
rendered paste body
in RHEL5, to resize a root partition which is a logical volume:

can't do it mounted, but it's root, so can't unmount it. Here, I want to reduce my / partition to 6GB:

boot into rescue, do not mount existing system

run:

#lvm pvscan

#lvm lvscan

This should show your partition, eg. /dev/VolGroup00/LogVol00

now run 

#lvm vgchange -a y /dev/VolGroup00/

#lvm lvscan 

 - this will now show active volumes

now run

#e2fsck -f /dev/VolGroup00/LogVol00

#then run

resize2fs /dev/VolGroup00/LogVol00

this will show you how many sectors are in the FS right now. Work out roughly how big you want it to be as a proportion of the current value, and run

#resize2fs /dev/VolGroup00/LogVol00 <number of sectors> - work out a number of sectors which is just below your desired LV size


now to reduce the LV itself:

lvm lvreduce -L 6G /dev/VolGroup00/LogVol00

yay!

You should then resize your filesystem to fill up the whole LV but I couldn't be buggered.