Skip to contentSkip to conversation

pv recovery after trashing partition table.

linux-lvm Jim Cromie 2 participants 2 messages Oct 13, 2001

lore
Share & tools
lore

Jim Cromie

author
#0 lore raw

again, thanks Andreas,

Having read to the end of man gpart, I encountered the useful -

gpart -vdg /boot/boot.bak

which I had lying around (good luck again). The output(s) confirm that my manually fdisk'd partition matches the original.

So somehow I managed to corrupt hda4 at about the same time that I blanked the MBR. I dont know how, but Ill accept that theyre causally (not casually) related.

I looked a bit at gpart's partition-type-guessing code, it shouldnt be too hard to work out which bytes are failing gpart's guesser. Getting LVM to accept my hacks may be much harder.

So how big is an LVM super-block ?

I always have the (probably 1-way) fallback - a partion type change, then an fsck to see what it finds.

#1 lore raw
Quoted 7 lines · Jim Cromie

So somehow I managed to corrupt hda4 at about the same time that I blanked the MBR. I dont know how, but Ill accept that theyre causally (not casually) related.

I looked a bit at gpart's partition-type-guessing code, it shouldnt be too hard to work out which bytes are failing gpart's guesser. Getting LVM to accept my hacks may be much harder.

Well, I just ran gpart on a system I have with LVM partitions, and it does detect them properly.

Quoted 1 line

So how big is an LVM super-block ?

There are several parts to the LVM metadata. The PV data (first on the partition), the VG data (next), LV data, and then the PE map. Because LVM metadata has been known to have problems in the past, one thing you can try is to restore the metadata from backups (see vgcfgrestore).

The real problem is that the start of the filesystem depends on how big the actual disk is, and the alignment. If any of the LVM data is there, doing something like "od -Ax -a /dev/hda4 | more", or even better "strings -tx /dev/hda4" should show you the VG name, LV names, etc (along with other stuff, of course). If you find such data, it may be possible to reconstruct your LVM setup, or at least recover the data.

Quoted 2 lines

I always have the (probably 1-way) fallback - a partion type change, then an fsck to see what it finds.

It will find nothing, because the filesystem doesn't start until (maybe) a few MB into the partition. Any fsck program will expect the filesystem to start right at the beginning.

Cheers, Andreas
--
Andreas Dilger \ "If a man ate a pound of pasta and a pound of antipasto,
\ would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/ -- Dogbert