• 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

How to recover deleted Logical volume (LV) in LVM using vgcfgrestore

by admin

You have accidentally removed a logical volume lv01 from the Volume group vg01. Now you want to recover the LV without losing the data. Follow the steps given below to recover LV (lv01) under VG (vg01).

# lvremove vg01/lv01
Do you really want to remove active logical volume vg01/lv01? [y/n]: y
  Logical volume "lv01" successfully removed

Recovering remove LV

1. Verify the archive file under the directory /etc/lvm/archive when the logical volume was removed. In my case the file with latest timestamp under the /etc/lvm/archive directory will have the required information on the deleted volme lv01.

# cd /etc/lvm/archive/
# ls -lrt
total 16
-rw-------. 1 root root 1752 Oct 11 22:20 cl_00000-2084244320.vg
-rw-------. 1 root root 1111 Oct 13 20:05 vg01_00000-1050327195.vg
-rw-------. 1 root root 1112 Oct 13 20:06 vg01_00001-86976415.vg
-rw-------. 1 root root 1515 Oct 13 20:09 vg01_00002-1315455408.vg

2. Before running the actual restore you can do a dry run using the –test switch as shown below.

# vgcfgrestore vg01 --test -f /etc/lvm/archive/vg01_00002-1315455408.vg 
  TEST MODE: Metadata will NOT be updated and volumes will not be (de)activated.
  Restored volume group vg01

3. If the above dry run is successful, do the actual restore.

# vgcfgrestore vg01  -f /etc/lvm/archive/vg01_00002-1315455408.vg 
  Restored volume group vg01

4. Verify if the deleted volume has been successfully restored or not using ‘lvscan’.

# lvscan
  inactive          '/dev/vg01/lv01' [10.00 GiB] inherit
  ACTIVE            '/dev/cl/swap' [2.00 GiB] inherit
  ACTIVE            '/dev/cl/root' [17.00 GiB] inherit

5. As shown in the output the Logical volume lv01 is successfully restored from the metadata backup of VG. Activate the LV to access the data onto it.

# lvchange -a y /dev/vg01/lv01

6. Mount the logical volume and verify if the data is intact.

# mount /dev/mapper/vg01-lv01 /data
# ls /data
file1  file2  file3  lost+found
# df -hP /data
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/vg01-lv01  9.8G   37M  9.2G   1% /data

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to uninstall mingw-w64 from Ubuntu
  2. Extend volume on non-partitioned disk (XFS) under VMware guest
  3. ss Command Examples in Linux
  4. userdel Command Examples in Linux
  5. Understanding rsyslog Templates
  6. How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  7. CentOS / RHEL 7 : How to set udev rules for ASM on multipath disks
  8. ndctl: command not found
  9. How to uninstall neovim from Ubuntu
  10. How to move /usr and /var to Another Partition or Disk

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright