• 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. CentOS / RHEL 6,7 : How to configure hugepages
  2. SSH Login Stuck At : “debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP” CentOS/RHEL 7
  3. Understanding How Umask Controls the Initial File / Directory Permissions in Linux
  4. nohup Command Options in Linux
  5. “java” command does not run the JVM that has been installed
  6. Linux OS Service ‘anacron’
  7. How to Disable the ‘lvm2-lvmetad.socket/service’ on CentOS/RHEL 7
  8. The Squid Service in Failed State with Error: “Failed to make swap directory /var/spool/squid/00: (13) Permission denied”
  9. CentOS / RHEL 5 : How to install and configure vsftpd server
  10. CentOS / RHEL 6,7 : How to disable or delete virbr0 interface

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright