Course contentsShow
← Linux
Lesson 685 of 1,8197. Storage Management and Logical VolumesFree lesson

Disaster recovery with LVM metadata

Reconstruct volume groups from raw metadata header backups on alternative storage.

In this lesson, you will learn how to recover an entire Volume Group (VG) by manually reconstructing its metadata from automated backups after a disk header failure.

Understanding Metadata Backups

Whenever you modify an LVM configuration, LVM automatically saves a backup of your current metadata in the /etc/lvm/backup/ directory. These text files contain a complete map of your Volume Groups, Physical Volumes (PVs), and Logical Volumes (LVs). If a disk’s metadata header (the small area at the start of the drive that describes the LVM structure) becomes corrupted or is accidentally overwritten, your system will no longer see the VG. Even if the actual data on the disk is safe, LVM won't know how to assemble it.

The Recovery Process

To recover a lost VG, you must first ensure the physical disk is visible to the system. Once the hardware is detected, you can point LVM to your stored backup file to restore the configuration to the disk headers.

If you have a backup file named my_vg_backup, you can perform a metadata restore using the vgcfgrestore command:

# Verify the physical volume exists
pvscan

# Restore the metadata from the backup file
vgcfgrestore -f /etc/lvm/backup/my_vg_backup my_vg

After running vgcfgrestore, LVM writes the configuration back to the metadata area of the physical volumes associated with that Volume Group. Once the headers are restored, you must activate the volume group to make the logical volumes accessible again:

vgchange -ay my_vg

Why This Works

The data stored on your LVs is "dumb"—it exists as blocks on the disk platter or flash cells without knowing about its logical structure. The metadata acts as the "instruction manual" that tells the Linux kernel how to piece those blocks together into a usable volume. By keeping backups of these files in /etc/lvm/backup/, you create a roadmap that allows you to rebuild the logical structure instantly without losing your actual data.

Key Takeaway: LVM metadata is the critical "map" for your storage; keeping consistent backups of the /etc/lvm/ directory allows you to reconstruct a lost Volume Group structure even if the physical disk headers are completely corrupted.