• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL : How to restore/recover a deleted volume group in LVM

by admin

Question : how to recover/restore a volume group if a system admin deleted it accidently

Solution

LVM takes a backup of the on-disk metadata before and after running any LVM operation on a PV/VG/LV. For example, if you create a new LV the backup of all the metadata for the VG before and after creating the new LV is backed up. 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]
# vgcfgrestore --list appvg
# appvg_00_00000-123456.vg

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-123456.vg  appvg
# Restored volume group appvg

You should now be able to see appvg using the vgs command.

Note: This procedure will only restore the LVM metadata, making the Volume Group visible again. If actual data has been deleted from the disk, that will have to be restored using different methods (backup, etc.).

Once the Volume Group has been restored, a manual check for the actual on-disk data should be run. The procedure is only to restore the metadata of the Volume group. So there is no substitute for the actual data backup, in case if some one deletes that too.

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. chfn Command Examples in Linux
  2. Shell Script to print pyramid of Stars
  3. Using vmstat to troubleshoot performance issues in Linux
  4. localectl: command not found
  5. apache2ctl: command not found
  6. How to Setup VNC Server for New User in CentOS/RHEL 5
  7. mpirun.openmpi: command not found
  8. mkswap Command Examples in Linux
  9. How to mount USB flash drive in Linux
  10. RCRON – Setup High Availability of cron Jobs

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright