Resize Root Filesystem in Logical Volume

For CentOS and other linux distros which using LVM, sometimes it’s necessary to resize the root partition. Unfortunately, we can’t ‘just’ resize the mounted partition. By using step-by-step below, we can resize the root partition using Linux live CD, in this case I use Fedora 15 beta live CD. Here’re the steps:
1. Boot from live CD.
2. Open terminal window
3. Do not mount the filesystems
4. At the shell type: lvm
5. Within lvm shell, run following commands:
lvm> vgscan
lvm> vgchange –available y VolGroup00
lvm> lvscan # should show the LV as “ACTIVE”; the devices in /dev it mentions should now exist
lvm> exit
6. Now resize the filesystem with this command (e.g. using device /dev/VolGroup00/LogVol00):
e2fsck -f /dev/VolGroup00/LogVol00 # check filesystem
resize2fs /dev/VolGroup00/LogVol00 nnG # resize the fs to nn GB; nn should be less than the current fs size
e2fsck -f /dev/VolGroup00/LogVol00 # recheck filesystem
7. Run lvm again and type:
lvm> lvreduce -LnnG /dev/VolGroup00/LogVol00 # resize the LV to nn GB; nn should be the same as above
lvm> exit
8. Do another filesystem check:
e2fsck -f /dev/VolGroup00/LogVol00
9. Reboot and remove CD.

If you get the warning of resizing currently ACTIVE LV, please do the following from command line:
lvchange -a n VolGroup00/LogVol00 # to deactivate LV
and after operation above do:
lvchange -a y VolGroup00/LogVol00 # to reactivate LV

Credit to: coreychch
Mostly taken from: http://www.linuxquestions.org/questions/linux-newbie-8/lvm-and-shrinking-the-root-filesystem-327292/

Resize Root Filesystem in Logical Volume

2 thoughts on “Resize Root Filesystem in Logical Volume

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s