12.5. Restoring metadata on an LVM physical volume
This procedure restores metadata on a physical volume that is either corrupted or replaced with a new device. You might be able to recover the data from the physical volume by rewriting the metadata area on the physical volume.
Do not attempt this procedure on a working LVM logical volume. You will lose your data if you specify the incorrect UUID.
Conditions préalables
- You have identified the metadata of the missing physical volume. For details, see Finding the metadata of a missing LVM physical volume.
Procédure
Restore the metadata on the physical volume:
pvcreate --uuid physical-volume-uuid \ --restorefile /etc/lvm/archive/volume-group-name_backup-number.vg \ block-device# pvcreate --uuid physical-volume-uuid \ --restorefile /etc/lvm/archive/volume-group-name_backup-number.vg \ block-deviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe command overwrites only the LVM metadata areas and does not affect the existing data areas.
Exemple 12.4. Restoring a physical volume on /dev/vdb1
The following example labels the
/dev/vdb1device as a physical volume with the following properties:-
The UUID of
FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk -
The metadata information contained in
VG_00050.vg, which is the most recent good archived metadata for the volume group
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
The UUID of
Restore the metadata of the volume group:
vgcfgrestore myvg
# vgcfgrestore myvg Restored volume group myvgCopy to Clipboard Copied! Toggle word wrap Toggle overflow Display the logical volumes on the volume group:
lvs --all --options +devices myvg
# lvs --all --options +devices myvgCopy to Clipboard Copied! Toggle word wrap Toggle overflow The logical volumes are currently inactive. For example:
LV VG Attr LSize Origin Snap% Move Log Copy% Devices mylv myvg -wi--- 300.00G /dev/vdb1 (0),/dev/vdb1(0) mylv myvg -wi--- 300.00G /dev/vdb1 (34728),/dev/vdb1(0)
LV VG Attr LSize Origin Snap% Move Log Copy% Devices mylv myvg -wi--- 300.00G /dev/vdb1 (0),/dev/vdb1(0) mylv myvg -wi--- 300.00G /dev/vdb1 (34728),/dev/vdb1(0)Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the segment type of the logical volumes is RAID, resynchronize the logical volumes:
lvchange --resync myvg/mylv
# lvchange --resync myvg/mylvCopy to Clipboard Copied! Toggle word wrap Toggle overflow Activate the logical volumes:
lvchange --activate y myvg/mylv
# lvchange --activate y myvg/mylvCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
If the on-disk LVM metadata takes at least as much space as what overrode it, this procedure can recover the physical volume. If what overrode the metadata went past the metadata area, the data on the volume may have been affected. You might be able to use the
fsckcommand to recover that data.
Verification steps
Display the active logical volumes:
lvs --all --options +devices
# lvs --all --options +devices LV VG Attr LSize Origin Snap% Move Log Copy% Devices mylv myvg -wi--- 300.00G /dev/vdb1 (0),/dev/vdb1(0) mylv myvg -wi--- 300.00G /dev/vdb1 (34728),/dev/vdb1(0)Copy to Clipboard Copied! Toggle word wrap Toggle overflow