Resizing an LVM

Chris Tyler chris at tylers.info
Mon Jun 4 03:03:19 UTC 2007


On Sun, 03 Jun 2007 17:37:12 -0400 Robert L Cochran wrote: 
> Here is what I believe I need to do.
> 
> 1. Boot the Fedora 7 DVD in rescue mode.
> 2. Do not mount the file system, instead just go to a shell prompt and
> 3. lvm vgscan
> 
> Gets the name of the volume group
> 
> 4. lvm vgchange -a y /dev/VolGroup00
> 
> Activates the volume
> 
> 5. e2fsck -f /dev/VolGroup00/LogVol00
> 
> Checks file system for errors
> 
> 6. resize2fs /dev/VolGroup00/LogVol00 119G
> 
> shrinks the file system down to 119 Gb
> 
> 7. fdisk
> 
> shrinks size of partition

Unfortunately, this will not work, because shrinking the LV will not
reduce the size of the PV.

If you need real partitions (not LVs) for the other operating systmes,
you are at the present time out of luck for a direct conversion, because
pvresize has not been implemented (see the manpage for lvm).

What you could do, though, is temporarily attach another disk (IDE, USB,
or FireWire), then:

1. Create a partition on the temp disk (fdisk).
2. Make that partition a PV (pvcreate).
3. Add that partition to your volume group (vgextend).
4. Migrate the data off the old PV to the new one (pvmove).
5. Remove the original PV from the VG (vgreduce)
6. Recreate the PV on the original disk, smaller than before. (fdisk
followed by pvcreate).
7. Add the recreated PV to the VG (vgextend).
8. Migrate the data from the temp disk to the original disk (pvmove).
9. Remove PV on the temp disk from your VG (vgreduce).

This is why it's a good idea, when setting up a new large disk for use
with LVM, to divide the disk into multiple partitions and use all of
them as PVs in the VG (instad of creating one big PV) -- it gives you
more flexibility to later move some of that space out of the VG so it
can be used for something else. (It also lets you do an in-situ
migration to RAID; if, for example, you have 5 PVs, you can migrate to
RAID PV-by-PV as long as you have 20% free space in your VG).

--
Chris Tyler
Fedora Daily Package - http://dailypackage.fedorabook.com




More information about the fedora-list mailing list