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?
  • What do you get from sudo pvs and pvdisplay /dev/sdb5? – derobert Sep 9 '14 at 17:01
  • You missed the argument to pvdisplay. sudo pvdisplay /dev/sdb5. I presume /dev/sdb is where the Mint install you're trying to recover lives? If not, which disk does it live on? – derobert Sep 9 '14 at 17:29
  • Yes, it should be on /dev/sd5. command finds nothing. – user17130 Sep 9 '14 at 17:38
  • Maybe they set up some LVM filter... Does grep -P '^\s*filter' /etc/lvm/lvm.conf give anything? – derobert Sep 9 '14 at 17:48
  • the readable /etc/lvm is now Manjaro aka Archlinux on /dev/sda, so I dont see what the use is. But anyways grep does not find anything. – user17130 Sep 9 '14 at 17:58

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.

  • I was able to recover the partition. Thx. One thing though: strings did not capture the closing } brackets. I used cat /dev/sdxx > data then used vim to find the correct file. Then I had to fsck the partition and hold down the y for a minute or two. But it worked. – user17130 Sep 9 '14 at 22:13
  • @user17130 odd about that fsck. Anyway, keep that image that you hopefully took around for a bit, just in case. Also may want to check what you used to recover vs. what's in /etc to be sure. – derobert Sep 10 '14 at 0:33
  • I don't understand how you did, what have you done after cat /dev/sdxx > data? What did you edit/remove from this data file? All parts that concern old config contents or You kept just the last config content version or all other data too? And also, you chose this file for the --restorefile options of the pvcreate command? And what about vgcfgrestore? – temp_user_4_commenting Jul 7 '18 at 1:59
  • @temp_user_4_commenting maybe you should ask your own question, since cat isn't anywhere in my answer AFAIK. – derobert Jul 7 '18 at 4:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.