home | list info | list archive | date index | thread index

[OCLUG-Tech] how to recover logical volumes from a damaged volume group?

  • Subject: [OCLUG-Tech] how to recover logical volumes from a damaged volume group?
  • From: "Robert P. J. Day" <rpjday [ at ] crashcourse [ dot ] ca>
  • Date: Fri, 14 Feb 2014 12:23:08 -0500 (EST)
  a forensic recovery challenge for you -- friend just handed me a
laptop in which there are two HDs, the second one being what *used* to
be the first drive so its structure is a standard boot drive, with
/boot, and a single volume group with a number of LVs inside it.

  one of the logical volumes on that second drive is for "home", which
is where he kept all his work. having upgraded to a faster, larger
primary drive (/dev/sda), he moved the original primary drive to be
the secondary drive (/dev/sdb), did a minimal install on the new
primary drive, and just manually mounted the *old* home logical volume
manually whenever he needed to restore some of his old work. in short,
what is now /dev/sdb is formatted as a single volume group, with a
number of logical volumes.

  the problem -- ironically following instructions *i* had written for
how to create a bootable SD card, he took a 2G image, and "dd"ed it by
accident to /dev/sdb instead of /dev/sdc (being so used to having a
single drive system that he unthinkingly chose /dev/sdb as the
target as he had always done).

  result? the first 2G of /dev/sdb has now been overwritten with a
bootable image, so "fdisk -l /dev/sdb" shows exactly what you would
expect: two small partitions. but it's clear that the rest of the hard
drive should still be there unharmed, so how easy is it to locate and
activate those logical volumes?

  i can see the backup file "/etc/lvm/backup/vg1", which seems to have
the proper info about the VG "vg1" and LV layout of /dev/sdb, and down
in the list of logical volumes, i can see the LV entry for "home",
which is all i want to recover. any thoughts on how one would do this,
given that /etc/lvm/backup/vg1 seems to be accurate?

  i asked about this on the fedora user list, and got a couple
suggestions regarding running "pvck" and "pvscan" and so on, but i'm
not an LVM expert, so i want to make sure i start with utilities that
do nothing but *check* the disk, and if i can activate the volume
group and LVs on that second disk with nothing but the contents of the
backup file, that would be ideal.

  thoughts? do i need to post the contents of that file? it's about
150 lines long so it's not overly cumbersome.

rday

p.s. there is a backup of the disk, so it's not like this is an urgent
operation; it's more like an intellectual challenge.

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================