recommendations on how to recover a corrupted, LVM-based hard drive?

Robert Nichols rnicholsNOSPAM at comcast.net
Sat Feb 15 19:16:50 UTC 2014


On 02/15/2014 10:12 AM, Robert P. J. Day wrote:
>    at this point, before i go any further, if my math is correct, is
> there some command that can be used to ask, "if i *tell* you that a PV
> started at this offset, and the first part of it is trashed, can you
> tell me what you can find in the *rest* of the PV if it should contain
> valid LVs further down"?

All of the LVM metadata is at the beginning of the PV, so it's been
trashed.  The rest is just raw content -- nothing specific to LVM.

You can see this for yourself fairly easily.  First, create a large
sparse file to use as your volume.

    dd if=/dev/null bs=1k seek=1024k of=/var/tmp/test.img

That creates a 1GB file that currently uses no space on the disk.

    # losetup -f --show /var/tmp/test.img
    /dev/loop0
    # pvcreate /dev/loop0
      Physical volume "/dev/loop0" successfully created
    # vgcreate testvg1 /dev/loop0
      Volume group "testvg1" successfully created
    # lvcreate -l 25%FREE testvg1
      Logical volume "lvol0" created
    # lvcreate -l 100%FREE testvg1
      Logical volume "lvol1" created
    # echo "Start of testvg1-lvol0" >/dev/testvg1/lvol0
    # echo "Start of testvg1-lvol1" >/dev/testvg1/lvol1

At each stage you can run "hexdump -C /var/tmp/test.img | less"
and see what shows up there.  Beyond the first 384 sectors (offset
0x30000), the only non-zero lines will be the output from those
two "echo" commands.

-- 
Bob Nichols     "NOSPAM" is really part of my email address.
                 Do NOT delete it.



More information about the users mailing list