Loading...
 

Recovering Logical Volumes

Missing Metadata

Scenario

So after a new install onto a new disk, somehow the original Volume Group Metadata was lost. There was no record of the Volume group with any of the vg or pv commands. As this was a new install there was also no record of any backups in /etc/lvm/backup.

Finding the metadata backup from the physical volume

  1. Find out where the metadata backup resides on disk (offset=4096)
    TechOps1:/home/gbrown # pvck -d -v /dev/sda1
        Scanning /dev/sda1
      Found label on /dev/sda1, sector 1, type=LVM2 001
      Found text metadata area: offset=4096, size=192512
  2. hex dump the data from the partition
    hex -s 4096 /dev/sda1 |sed -e 's/^.\{56\}//g'|head -1500 > hexDump.txt
    this removes all of the unnecessary hex and just leaves the stuff we need
  3. reformat the data
    1. open the output file in a text editor and format it to look the same as one of the backups of the current system in /etc/lvm/backup/ or /etc/lvm/archive/ (if there isn’t any run vgcfgbackup)
  4. restore using the newly created backup file
    TechOps1:/home/gbrown # vgcfgrestore -f hexDumpModified.txt -v system
      Restored volume group system
  5. Import and activate the Volume Group
    TechOps1:/home/gbrown # vgimport system
      Volume group "system" successfully imported
    TechOps1:/home/gbrown # vgchange -ay
      4 logical volume(s) in volume group "TechOps1" now active
      4 logical volume(s) in volume group "system" now active
  6. Mount a volume
    TechOps1:/home/gbrown # mount /dev/system/root /mnt/
    TechOps1:/home/gbrown # ls !$
    ls /mnt/
    bin   .config  etc   lib    lost+found  mnt  proc        root  selinux  sys  usr
    boot  dev      home  lib64  media       opt  readme.txt  sbin  srv      tmp  var