LVM: Recovering Physical Volume Metadata

LVM: Recovering Physical Volume Metadata

# Tested on RHEL 5, 6 & 7

# If the volume group metadata area of a physical volume is accidentally overwritten or
# otherwise destroyed, you will get an error message indicating that the metadata area is
# incorrect, or that the system was unable to find a physical volume with a particular UUID.

   Couldn't find device with uuid 7GCY3s-1LYB-fhAF-kvu0-cCDm-9Q6m-s6xAQd.
   Couldn't find device with uuid 48rLN6-ztLy-nzqS-GM2a-9yvB-Cua5-wU826d.


# You may be able to recover the data the physical volume by writing a new metadata area
# on the physical volume specifying the same UUID as the lost metadata.

# UUID for the physical volume that was overwritten can be found in the /etc/lvm/archive
# directory. Look in the file
testvg_<00044-439430220>.vg for the last known valid
# archived LVM metadata for that volume group.


# If possible, before beginning, take a backup of F.S. existing on the Volume Group

VG=testvg

# umount F.S.

FS=""

for LV in `lvs --noheadings /dev/$VG | awk '{print$1}'`; do FS="$FS `mount | grep "$VG-$LV" | awk '{print$3}'`"; done

for FS in $FS; do umount $FS; done


# Deactivate the Volume Group

vgchange -an --partial $VG
  Partial mode. Incomplete volume groups will be activated read-only.
  0 logical volume(s) in volume group "testvg" now active



# Restore the right UUID (the lost ones) on the adequate Physical Volumes (match between disk
# and UUID can be found in valid /etc/lvm/archive/
testvg_<00044-439430220>.vg file)

pvcreate -ff --uuid "7GCY3s-1LYB-fhAF-kvu0-cCDm-9Q6m-s6xAQd" --restorefile /etc/lvm/archive/testvg_00044-439430220.vg /dev/mpath/mpath9p1
   Really INITIALIZE physical volume "/dev/mpath/mpath9p1" of volume group "testvg" [y/n]? y
      WARNING: Forcing physical volume creation on /dev/mpath/mpath9p1 of volume group "testvg"
      Physical volume "/dev/mpath/mpath9p1" successfully created


pvcreate -ff --uuid "48rLN6-ztLy-nzqS-GM2a-9yvB-Cua5-wU826d" --restorefile /etc/lvm/archive/testvg_00044-439430220.vg /dev/mpath/mpath12p1
   Really INITIALIZE physical volume "/dev/mpath/mpath12p1" of volume group "testvg" [y/n]? y
     WARNING: Forcing physical volume creation on /dev/mpath/mpath12p1 of volume group "testvg"
     Physical volume "/dev/mpath/mpath12p1" successfully created



# Restore Volume Group's metadata

vgcfgrestore $VG
   Restored volume group testvg


# Activate Logical Volumes

for LV in `l
vs --noheadings /dev/$VG | awk '{print$1}'`
do
   lvchange -ay /dev/$VG/$LV
done



# Verify that Logical Volumes are available

vgdisplay -v $VG | egrep "LV Name|LV Status"

# Check that you don't have the errors regarding the devices not found

   Couldn't find device with uuid 7GCY3s-1LYB-fhAF-kvu0-cCDm-9Q6m-s6xAQd.
   Couldn't find device with uuid 48rLN6-ztLy-nzqS-GM2a-9yvB-Cua5-wU826d.



# Mount F.S.

# If declared in /etc/fstab:
for FS in $FS; do mount $FS; done
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
stunnel basics and pki standards
Viewed 9390 times since Fri, Sep 28, 2018
Increase A VMware Disk Size (VMDK) Formatted As Linux LVM without rebooting
Viewed 15303 times since Wed, May 30, 2018
logrotate Understanding logrotate utility
Viewed 1741 times since Sun, Jan 12, 2020
LVM: Remove an existing Volume Group
Viewed 5295 times since Sat, Jun 2, 2018
Need to set up yum repository for locally-mounted DVD on Red Hat Enterprise Linux 7
Viewed 3019 times since Mon, Oct 29, 2018
Fake A Hollywood Hacker Screen in Linux Terminal linux FUN
Viewed 5780 times since Thu, Apr 18, 2019
RHCS6: Debug and test multicast traffic between two hosts
Viewed 6548 times since Sun, Jun 3, 2018
Top 20 OpenSSH Server Best Security Practices ssh linux aix
Viewed 5849 times since Fri, May 15, 2020
Inxi – A Powerful Feature-Rich Commandline System Information Tool for Linux
Viewed 18852 times since Sat, Jun 2, 2018
www.unixarena.com
Viewed 2363 times since Fri, Jul 27, 2018