How can I resize a LVM partition in Red Hat without lose of data?

My partition detail is like this

/dev/mapper/VolGroup00-LogVol00
                       57G  8.8G   46G  17% /
/dev/mapper/VolGroup00-LogVol05
                      259G  7.0G  239G   3% /home
/dev/mapper/VolGroup00-LogVol02
                       19G  493M   18G   3% /var
/dev/mapper/VolGroup00-LogVol03
                       19G  458M   18G   3% /tmp
/dev/mapper/VolGroup00-LogVol04
                      9.5G  152M  8.9G   2% /opt
/dev/sda1             965M   33M  883M   4% /boot
tmpfs                 7.7G  3.7G  4.0G  48% /dev/shm

I want to increase the size of the / by reducing the size of the /home partition, without lose of data in the / and home.

Can anybody help me in solving this issue?


Solution 1:

  • Boot with a live distro (lvm capable)
  • don't mount your lvm partitions
  • fsck LogVol00 and LogVol05 (twice this step)
  • lvreduce -L-xG /dev/VolGroup00/LogVol05
  • resize2fs -p /dev/VolGroup00/LogVol05

do the same for /dev/mapper/VolGroup00-LogVol00 with lvextend instead of lvreduce

Solution 2:

I second vishaal's answer, however he left out a couple steps..as well as the fact you can do this with linux rescue

  1. Boot into linux rescue
  2. skip mounting
  3. run lvm vgchange -a y (in rescue mode you preface the commands with lvm)
  4. verify visibility by OS with ls /dev/VolGroup00/
  5. The rest is much like vishaal described, but you'll want to force the e2fsck with a -f ie: e2fsck -f /dev/VolGroup00/LogVol..

  6. IMPORTANT, you resize the filesystem before you reduce the volume, so..

  7. resize2fs -f /dev/VolGroup00/LogVol.. 40G (if you wanted the size to be exactly 40G)
  8. lvm lvreduce -L40G /dev/VolGroup00/LogVol.. (again if you wanted the size to be exactly 40G and not reduced by 40G)

Mine is simply an addition to what advice vishaal has already given.