LVM – Recovering Metadata Without Access to /etc/lvm/

data-recoverylvm

I just installed Manjaro on to a externalized usb hard drive. After I was done, I tried to boot from my previously working Mint distro (no full-disk luks) on my internal hard drive. The lvm volume groups had disappeared!?

    [crow ~]$ sudo lvm vgscan
    [sudo] password for crow:
      Reading all physical volumes.  This may take a while...
      Found volume group "ManjaroVG" using metadata type lvm2
    [crow ~]$ sudo pvscan
      PV /dev/mapper/cryptManjaro   VG ManjaroVG   lvm2 [465.51 GiB / 0    free]
      Total: 1 [465.51 GiB] / in use: 1 [465.51 GiB] / in no VG: 0 [0   ]
    [crow ~]$ sudo fdisk -l /dev/sdb

    Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 976773168 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x00079473

    Device     Boot  Start       End   Sectors   Size Id Type
    /dev/sdb1  *      2048    499711    497664   243M 83 Linux
    /dev/sdb2       501758 976771071 976269314 465.5G  5 Extended
    /dev/sdb5       501760 976771071 976269312 465.5G 8e Linux LVM

    [crow ~]$ sudo pvs
    [sudo] password for crow:
      PV                       VG        Fmt  Attr PSize   PFree
      /dev/mapper/cryptManjaro ManjaroVG lvm2 a--  465.51g    0
    [crow ~]$ sudo pvdisplay
      --- Physical volume ---
      PV Name               /dev/mapper/cryptManjaro
      VG Name               ManjaroVG
      PV Size               465.51 GiB / not usable 2.00 MiB
      Allocatable           yes (but full)
      PE Size               4.00 MiB
      Total PE              119170
      Free PE               0
      Allocated PE          119170
      PV UUID               B8f73k-Najv-6hVM-XxHm-Wk9F-zeZ9-69MsxN

    [crow ~]$ sudo pvdisplay /dev/sdb5
      Failed to find physical volume "/dev/sdb5"

     [crow ~]$ sudo file -s /dev/sdb5
     /dev/sdb5: data

I have switched the disks around and now the non-working disk is /dev/sdb.
I have read that there is meta data backup in /etc/lvm which is of course inside /dev/sdb5 and not /boot at /dev/sdb1.
I would like to see a better answer for this.


If there is not a way to restore the disks then what are my options? Are these among them?

  • Are there any forensics tools that can give access to the data?
  • Another thing is the partition scheme was the standard linux Mint. If
    I reinstalled Mint could the new meta-data be used to try to recover
    the old?

Best Answer

It appears that the header did get cleared off your physical volumes. Thankfully, LVM stores a fairly large header, including multiple backups of the metadata, in plain text.

So you can find the plain-text metadata using, e.g., sudo strings /dev/sdb5 | less and use that metadata to restore the physical volume. Note that there will possibly be multiple copies from different dates; make sure to use the most-recent (there is a date stamp in them). Once you've used strings (and some hand-editing of its output, possibly) to get a config backup, you can use the steps in the CentOS LVM recovery documentation to restore access to the volume group.

I strongly recommend making an image of the partition before attempting recovery.

Related Question