[linux-lvm] Need help with PV recovery

Andreas Dilger adilger at turbolabs.com
Mon Dec 31 01:47:01 UTC 2001

On Dec 30, 2001  18:40 -0500, Matt Zimmerman wrote:
> During a different recovery operation, the first sector of one of my PVs was
> partially corrupted (it had bootsector data written to it).  Some of the
> metadata is still intact; in particular, the total/free/allocated statistics
> look reasonable, part of the PV UUID is still there, the volume group
> configuration is still there, and all of the LE->PE mappings seem to be OK.
> It seems like this situation should be recoverable, but so far I have been
> unsuccessful.  After backing up the beginning of the partition, I tried
> patching it up by hand with little success, then I tried pvcreate -ff and
> vgcfgrestore.  While pvdisplay seems to show the right data after that,
> vgscan still doesn't recognize the volume.
> Attached is the result of "pvdata -a" on the (unmodified) partition.

> --- Physical volume ---
> PV Name               /dev/scsi/host1/bus0/target0/lun0/part1
> VG Name               D
> PV Size               8.43 GB / NOT usable 4.48 MB [LVM: 132.00 KB]
> PV#                   0
> PV Status             NOT available
> Allocatable           yes
> Cur LV                7
> PE Size (KByte)       4096
> Total PE              2158
> Free PE               681
> Allocated PE          1477
> PV UUID               EffefH-Zmr5-gMrs-rUEM-

So, what you need to do (approximately) is (bPV = broken PV):

# restore the LVM magic at the start of the PV (probably OK, but why not)
dd if=/dev/<some other PV> bs=1 count=4 of=<bPV>
# restore the UUID (obviously broken)
echo -e "EffefHZmr5gMrsrUEM6CkDRRZC1ragTp\0" | dd bs=1 seek=44 count=33 of=<bPV>
# restore the VG name (looks to be missing)
echo -e "<vgname>\0" | dd bs=1 seek=172 count=<length of vgname + 1>

According to the UUID list, this _should_ be PV #2, is that correct?
Hard to see if the "system id" is OK, but I'm not sure if it is important.
What about the output of "pvdata -PP <bPV>"?  I _assume_ that the PV
location data is OK, or you wouldn't be getting anything from the
PE and LV lists, but it is hard to tell for sure.

What would be also useful is the first 40 lines of "od -Ax -tx4 <bPV>".

Cheers, Andreas
Andreas Dilger

More information about the linux-lvm mailing list