Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
It's a good idea to leave unallocated space in the volume group to hand out to needy LVs in future. It's part of the benefits of using LVM. Otherwise you end up in this situation. –  Allen Jun 7 '09 at 17:45
add comment

6 Answers 6

  • 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

share|improve this answer
2  
This assumes Charly is using ext. While most filesystems can be shrunk no problem, XFS (for example) can only be grown, never shrunk. –  Scott Pack May 28 '09 at 13:09
add comment

Basic instructions here. I wouldn't try it without a recent known-good backup personally.

share|improve this answer
add comment

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.

share|improve this answer
add comment

A minor tweak to the process given by vishaal and Bobby Cox:

  • resize2fs the /home LV down to a bit smaller than you really want
  • lvm lvreduce it down to the size you really want
  • resize2fs it back up to fill the LV (by not specifying a size)

This leaves a safety margin on the off-chance that the two commands interpret explicit sizes differently (I know the lvm commands round to an integer number of Extents; how the default Extent size is determined I'm not sure, and don't really care).

When increasing an LV's size the procedure is somewhat simpler:

  • lvm lvextend to the size you want
  • resize2fs to fill
share|improve this answer
add comment

You don't have to reboot to do this; however make sure you have a fresh backup at hand.

  • Close all your user sessions.
  • Login as root. If you need to login as a user first, use "exec su -" or "exec sudo -i" so as not to leave your user logged in and preventing a clean umount
  • Find out if anything is still using /home with "lsof -n | grep /home"; terminate the processes that do
  • umount /home
  • Figure the new size you want in bytes, make it a multiple of the LVM extents size, let's call it $newsize
  • fsck /dev/mapper/VolGroup00-LogVol05
  • resize2fs -P /dev/mapper/VolGroup00-LogVol05 $newsize
  • lvreduce -L $newsze /dev/mapper/VolGroup00-LogVol05
  • mount /home

That's, of course, assuming you use ext[234].

share|improve this answer
add comment

Want to re-iterate:

When shrinking, resize the FS first then resize the LVM When extending, resize the LVM first, then resize the FS.

When shrinking, you do need to umount the volume. When extending, depending on your linux kernel, you can do it online while system is mounted

When shrinking, crucial to have backups When extending, very very very very good idea to have backups (when is it not) but not as risky as when shrinking

Other than that, everyone else is spot on

share|improve this answer
    
The -r option to lvreduce handles this for you. –  Michael Hampton Feb 21 at 1:08
    
:D sysadmins are creatures of habit. Hadn't heard of that, thanks!! –  ben Mar 4 at 20:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.