Skip to content

Fusion Network

Shrink a LVM with LiveCD

Howto Shrink a LVM on your system
You can Shrink an LVM using Ubuntu, Fedora, etc...

This is something that i have had to do several times at this point so i figured it is time for me to write something about it.  (Click read more for details)



There are a few things that you should have or do before getting started.
    1. Make a backup!!! I cant stress this enough. This process has a potential of destroying your data!
    2. A linux Live CD with lvm2 support (Ubuntu live or Fedora Core 11 live are the ones i have used.)
    3. A system to resize stuff on!
    
Getting started:
 I think it goes without saying that you should always have a backup of your system before doing something like this. If you want to make a full disk image of your computer and have the room on an external hard drive or another computer on your network i highly suggest "CloneZilla". This tool will allow you to make backups of many different types of partitions. You can save your backups to a local disk(internal or external) or even to another server via samba or ssh. You can run CloneZilla off a liveCD to make the whole process easy as can be. There really is no reason to NOT have a backup. That being said.. If you loose your data doing this and dont have a backup. I told you so!
 From here on i will list what I did to make this work for me. It might not work for you but ive done this several times on several different Linux computers.
 
 1. Boot the computer off of your linux LiveCD of choice. I used Ubuntu 9.04 this time.
 2. Make sure that you have lvm2 once your LiveCD is booted. I have to install it on ubuntu's LiveCD (apt-get install lvm2 -y)
 3. Active the LVM.  At command line type: "vgchange -ay"
 4. Locate your LVM disk. Mine is here /dev/mapper/VolGroup00-LogVol00
 5. Run a filesystem check. "e2fsck -f /dev/mapper/VolGroup00-LogVol00"
 6. Resize the filesystem (To 75GB in this example.. Down from 100GB). "resize2fs /dev/mapper/VolGroup00-LogVol00 75G"
 7. Reduce the size of the Logical Volume. "lvreduce -L 76G /dev/mapper/VolGroup00-LogVol00"
 8. You should be done... Reboot your system and run "df -h" in a console. It should report back that your base disk is now set to 75GB.

 

Update: Guess your not out of the woods yet soldier. Looks like LVM resize really just hates it when there is a "partition" that is set farther back than where you want to resize to...Rather than being smart and moving it for you, it will complain and give you a headake. Lucky for us this 'partition' is just swap and we can happily delete and recreate it without (hopfully) breaking to much..

I dont think i could write this any better than the great people of Fedora.. So follow in here: http://fedorasolved.org/Members/zcat/shrink-lvm-for-new-partition

 -E