Expanding an LVM partition at the front
Roberto Ragusa
mail at robertoragusa.it
Mon Feb 21 20:00:19 UTC 2011
On 02/21/2011 08:17 PM, Matthew Saltzman wrote:
> I deleted the partition immediately in front of an LVM physical volume.
> I'd like to use the freed space as part of the LVM volume group. I know
> I could create a new partition in the same place, make it a physical
> volume and add it to the group, but because the space is contiguous, I
> wondered if it is possible just to move the front of the existing PV
> partition to include the freed space.
>
> I tried changing the start of the partition using fdisk, but then the PV
> is no longer recognized by LVM. I suppose that means that there is
> information about the PV stored in a particular location at the front of
> the partition. Putting the starting point back makes the PV
> recognizable again.
>
> So is there a utility that can move the front of a physical volume
> partition? (gparted and fdisk apparently can't).
What you are attempting is quite dangerous.
I don't know if automated tools exist for this, but you should
do this:
let's suppose you have this layout
partition 5 cyl 1600-1999 empty space
partition 6 cyl 2000-2999 existing PV
- destroy partition 5 and 6 with fdisk (not joking!)
- copy data from 2000-2999 to 1600-2599 (dd on /dev/sda with appropriate bs,seek,skip,count)
- now create partition 5 on 1600-2599
At this point you should have your PV available again and you
have simplified your problem to "I want to enlarge a PV", which you can do
with fdisk (part5 from 1600 to 2999) and pvresize.
Another probably much safer solution would be:
- get a spare disk (even USB external one)
- create new PV, add to VG, pvmove your PV to the new PV
- destroy and recreate your PV
- pvmove from USB PV to enlarged PV
- remove USB PV
This is less error prone. It can happen while the filesystem is R/W mounted too.
--
Roberto Ragusa mail at robertoragusa.it
More information about the users
mailing list