Friday, 28 September 2018

How to restore/recover a deleted VG in LVM

LVM takes a backup of the on-disk metadata before and after running any LVM operation on a PV/VG/LV. 

These backups are stored in
1. /etc/lvm/archive: contains copies taken before executing a command.
2. /etc/lvm/backup: contains copies taken after executing a command.

Listing available backups

The backup files can also be found using the vgcfgrestore command. The command lists all the available backups of metadata before any LVM operations.
# vgcfgrestore --list   <vg-name>

Restoring the metadata

Once the correct backup file has been found, the metadata contained in it can be written back to the devices belonging to that Volume Group using the vgcfgrestore command:
# vgcfgrestore -f /etc/lvm/archive/[backup_file] [vg-name]
For Example:
# vgcfgrestore -f /etc/lvm/archive/appvg_00_00000-988080.vg  appvg
# Restored volume group appvg
You should now be able to see appvg using the vgs command.

No comments:

Post a Comment