From: Andreas Dilger <adilger@turbolabs.com>
To: timshel@pobox.com
Cc: linux-lvm@sistina.com
Subject: Re: [linux-lvm] Fixing corrupted LVM PV headers?
Date: Thu Jan 3 15:25:01 2002 [thread overview]
Message-ID: <20020103142740.A12868@lynx.no> (raw)
In-Reply-To: <3C352FFF.1946.1910201@localhost>; from timshel@pobox.com on Fri, Jan 04, 2002 at 04:30:55AM +1100
On Jan 04, 2002 04:30 +1100, timshel@pobox.com wrote:
> I've been using LVM on my home system for quite some time now, and I
> have just recently install Windows XP, which totally stuffed up my
> partitioning for some reason. Anyway, in the process of fixing the
> stuff up I've managed to corrupt the first 3 sectors or so (at least, I
> hope it's only 3 sectors) of one of the physical volumes that make up
> my main volume group. So I've effectively lost my entire Linux system.
>
> I'd rather not have to reinstall from scratch, as there was quite a bit
> of stuff on some of the filesystems that would take me some time to
> replace, so I'm wondering if there is any way of resurrecting the PV.
> I've got the UUID of the PV (from running pvdisplay on the other PV's
> in the group and working out which one was missing) ... If it's not
> possible to recover the filesystem(s) that were on that particular PV,
> would it be at all possible to recover filesystems that are entirely on
> the other PV's?
>
> My setup is the following:
>
> hda6: 8Gb PV (This is the stuffed one)
> hda7: 8Gb PV
> hda8: 8Gb PV
> hdb6: 8Gb PV
> hdc: 3Gb PV
>
> There were 5 different LV's on the VG, all with XFS filesystems except
> for a swap volume.
>
> /usr ~4Gb LV
> /home ~2Gb LV
> /var: ~1.3Gb LV
> /var/share ~7Gb LV
> /var/chroot ~1Gb LV
>
> If anyone has any suggestions on possibilites for fixing this, please
> let me know ...
Well, this seems to become my specialty:
- Look in include/linux/lvm.h for descriptions of the LVM metadata (see
pv_disk_t, lv_disk_t, vg_disk_t, etc)
- You need to re-create the pv_disk_t struct at the start of the disk,
and also maybe the vg_disk_t (it starts at 1kB or 4kB offset normally).
- You need to have all of the data for the pv_disk_t. Some of it can be
found from the other PVs, some of it you will have to calculate.
- The majority of fields _should_ be the same as that on another PV of
_exactly_ the same size, assuming you added them with the same version
of LVM user tools. To start with, I would just do something like the
following to give you the basics, and allow you to just change specific
fields. You _need_ to have the exact same partition sizes for this to
work correctly, if you don't you need to do more work:
dd if=/dev/hda7 bs=1k count=1 of=/dev/hda6
- The vg_disk_t starts with the VG UUID, so if you find it at 4kB offset,
you are OK with that part. If not, you should be able copy the vg_disk_t
directly from another PV in the same VG. The offset will depend on what
version of tools you used to create your PV/VG, so it needs to be at the
value of vg_on_disk.base (either 1kB or 4kB offset into the PV):
dd if=/dev/hda7 bs=1k count=1 seek=<1k/4k> skip=<1k/4k> of=/dev/hda6
- Note that pv_uuidlist_on_disk.base and .size were changed (6kB or 8kB), so
you _should_ be able to determine the start of the UUID list by looking at
the disk with "od -Ax -tx4 /dev/hda6" and comparing the output to the UUIDs
on another PV.
- At this stage, running "pvdata -avP /dev/hda6" should give you reasonable
values back for the VG, LV, PE, and UUID data.
- You need to fix the fields pv_uuid, pv_number and pe_allocated, assuming
the original PV is exactly the same size. Normally I do this by either
echo -en "<value(s)>" | dd of=/dev/hda6 bs=1 count=M seek=N
where I echo things like "\0\0\0\001" (the latter being an octal number),
and M and N are appropriate byte offsets into the struct (per lvm.h). You
need to specify M (normally 4) because echo may append a trailing newline.
- If the PV sizes do not match, you also need to fix pe_on_disk.size, pv_size,
pe_total, and pe_start (maybe). I can tell you how to do this also, but
it is complicated so I'd rather not unless needed.
- At this point, vgscan should be able to detect the whole VG. If the
pe_on_disk.size value (and/or pe_start) is wrong, then you will get
misaligned data for your filesystems that have data on that PV, and you
have to work out the correct value.
Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/
next prev parent reply other threads:[~2002-01-03 15:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-03 11:30 [linux-lvm] Fixing corrupted LVM PV headers? timshel
2002-01-03 15:25 ` Andreas Dilger [this message]
2002-01-04 8:11 ` Timshel Knoll
2002-01-04 14:08 ` Andreas Dilger
2002-01-05 10:43 ` Timshel Knoll
2002-01-05 11:54 ` Timshel Knoll
2002-01-05 18:01 ` Andreas Dilger
2002-01-08 12:20 ` [linux-lvm] NEED HELP ON VGDA!! Prashant Kharche
2002-01-08 12:32 ` Andreas Dilger
2002-01-09 3:16 ` Joe Thornber
2002-01-08 13:37 ` mitch
2002-01-08 13:49 ` [linux-lvm] LVM on large drives David Orman
2002-01-08 16:24 ` Petro
2002-01-12 18:11 ` [linux-lvm] ERROR "pv_read(): PV identifier invalid David Orman
2002-01-13 4:54 ` Goetz Bock
2002-01-13 10:53 ` Glenn Shannon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020103142740.A12868@lynx.no \
--to=adilger@turbolabs.com \
--cc=linux-lvm@sistina.com \
--cc=timshel@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox