Resizing logical volumes

Paul Howarth paul at city-fan.org
Thu May 18 10:25:49 UTC 2006


Philip Prindeville wrote:
> Paul Howarth wrote:
> 
>> On Tue, 2006-05-16 at 23:15 +0200, Aad Rijnberg wrote: 
>>  
>>
>>> I have installed FC5 using LVM. During installation I chose the /usr volume 
>>> apparently too small, because now there is not enough room to install 
>>> updates.
>>>    
>>>
>> Before changing volume sizes, another option you might want to consider
>> is to remove a few large packages that you don't use. Doing this will
>> also have the advantage that you don't need to download and install
>> updates for these large packages if they appear.
>>
>> You can get a list of installed packages sorted by size like this:
>>
>> $ rpm -qa --qf '%{SIZE}\t%{NAME}\n' | sort -n
>>
>> You can then use "rpm -qi packagename" to get information about what a
>> particular package is if you don't know it, and "rpm -e packagename" (as
>> root) to get rid of it if you decide you don't want it. rpm will tell
>> you if there are other packages that depend on the one you're trying to
>> remove, and refuse to remove the package.
>>
>>  
>>
>>> To solve this problem, I would like to decrease my /home volume (LogVol03) by 
>>> some 3GB and increase the /usr volume (LogVol01) by the same amount. /home 
>>> physically resides on /dev/hda2 whereas /usr resides on /dev/hda3.
>>>    
>>>
>> The physical location of the volumes does not matter if they are in the
>> same volume group. In fact, how do you know where they are?
>>
>>  
>>
>>> I was thinking of using system-config-lvm for this. Is that a good idea?
>>>    
>>>
>> I don't know, I've never used it.
>>
>>  
>>
>>> Can this whole operation be executed without data loss?
>>>    
>>>
>> Yes.
>>
>>  
>>
>>> It is possible to execute 
>>> system-config-lvm while the partitions are mounted?
>>>    
>>>
>> It's not possible to run it when they're not mounted, since
>> system-config-lvm lives under /usr :-)
>>
>> I usually do this using the command-line tools. The general flow would
>> be:
>>
>> 1. Reduce the size of the /home filesystem by *more* than the amount you
>> eventually want to reduce it by (say 4G). This avoids the possibility
>> that due to rounding issues your filesystem may extend past the end of
>> the logical volume it's on when the logical volume is shrunk. You may be
>> able to do this online using ext2online. If it says it can't do it,
>> you'll need to go to single user mode, unmount /home and /usr, and use
>> resize2fs instead (and for the following steps too)
>>
>> 2. Reduce the size of LogVol03 by 3G, using lvreduce.
>>
>> 3. Resize /home to fill the logical volume it's on, again using
>> ext2online or resize2fs. By not specifying the size to use, the tool
>> will expand the filesystem to fill the volume.
>>
>> 4. Increase the size of LogVol01 by 3GB using lvextend.
>>
>> 5. Resize /usr to fill he logical volume it's on, again using ext2online
>> or resize2fs. By not specifying the size to use, the tool will expand
>> the filesystem to fill the volume.
>>
>> Paul.
>>
>>  
>>
> 
> Ok.. now what if they are on different volume groups and partitions? ;-)

Let's suppose you have a small root partition/volume and big /home 
partition/volume (sound familiar?). You want to allocate some space from 
/home to the root filesystem, but the two are in different volume groups 
for reasons best know to you.

This is not going to be easy because I know of no way to safely reduce 
the size of a physical volume other than backing up/moving the data 
elsewhere, deleting the physical volume and then creating a smaller one.
You could then use the remaining space to create a new partition and new 
physical volume, add that new physical volume to the volume group of the 
root filesystem and then extend the root filesystem as usual.

Paul.




More information about the fedora-list mailing list