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
linux manual tools
Viewed 2712 times since Fri, Sep 28, 2018
Linux An introduction to swap space on Linux systems
Viewed 2329 times since Thu, Jan 23, 2020
How to retrieve and change partition’s UUID Universally Unique Identifier on linux
Viewed 2956 times since Tue, Jul 17, 2018
RHEL: Crash kernel dumps configuration and analysis on RHEL 7
Viewed 6993 times since Sat, Jun 2, 2018
Monitoring bezpieczeństwa Linux: integracja auditd + OSSEC cz. I
Viewed 2369 times since Fri, Apr 5, 2019
10 Linux nslookup Command Examples for DNS Lookup
Viewed 10134 times since Sun, Sep 30, 2018
How To Use the Linux Auditing System on CentOS 7
Viewed 3831 times since Fri, Apr 5, 2019
How To Use Systemctl to Manage Systemd Services and Units
Viewed 7351 times since Mon, Dec 7, 2020
SSL HowTo: Decode CSR
Viewed 4897 times since Mon, Feb 18, 2019
zabbix linux How to solve apache error No space left on device: Cannot create SSLMutex
Viewed 2306 times since Wed, Nov 11, 2020