Resizing partition with LVM

Paul Howarth paul at city-fan.org
Thu Dec 22 18:24:41 UTC 2005


Reuben D. Budiardja wrote:
> Hello,
> I installed FC4 with "Automatic partitioning". Now I want to resize the 
> partition of / so that I can have free space (with no partition) to install 
> other OS. Here is how my system looks like:
> 
> ]# fdisk -l /dev/hda
> 
> Disk /dev/hda: 40.0 GB, 40007761920 bytes
> 255 heads, 63 sectors/track, 4864 cylinders
> Units = cylinders of 16065 * 512 = 8225280 bytes
> 
>    Device Boot      Start         End      Blocks   Id  System
> /dev/hda1   *           1          13      104391   83  Linux
> /dev/hda2              14        4864    38965657+  8e  Linux LVM
> 
> [root at nx-01 ~]# df -h
> Filesystem            Size  Used Avail Use% Mounted on
> /dev/mapper/VolGroup00-LogVol00
>                        35G  6.7G   27G  20% /
> /dev/hda1              99M   30M   64M  32% /boot
> 
> 
>>From LVM HowTo, it seems that I have to resize the filesystem first, then 
> resize the volume using lvreduce. I tried using parted by to resize the 
> partition and filesystem of /dev/hda2, but it complained about unknown 
> filesystem type.
> 
> So I am hoping for any help on how to resize /dev/hda2 so that I can have 
> about 10GB of free space. 

You're out of luck. I don't know of any tool that can shrink LVM 
physical volumes at the moment. If there was such a tool, the process 
would be to shrink the filesystem (/), then shrink the logical volume 
(/dev/VolGroup00/LogVol00), then shrink the physical volume (on 
/dev/hda2), and then shrink the partition.

The most straightforward way of working around this (other than backing 
up and reinstalling) would be (after shrinking the filesystem and 
logical volume) to add another hard drive to the system, create a new 
physical volume on it, add that volume to VolGroup00, use pvmove to move 
all of the allocated data to the new drive, remove the hda2 volume from 
VolGroup00, delete the hda2 partition, create your new partition table 
how you want it (including a new Linux LVM partition), create a new 
phsyical volume on your new Linux LVM partition, add that volume to 
VolGroup00, use pvmove to move all of the allocated data back to the 
original drive, remove the addition drive's physical volume from 
VolGroup00, and then remove the additional drive from your machine.

LVM is great for adding space to your existing setup, but not so hot on 
reducing it unfortunately.

Paul.




More information about the users mailing list