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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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 Create Disk Partitions using cfdisk
  2. How to monitor /etc/shadow and /etc/passwd file for changes with Auditd?
  3. CentOS / RHEL 6 : How to Save iptables Rules
  4. CentOS / RHEL 5,6 : How to Change the timezone
  5. CentOS / RHEL : How to configure a user account to never expire (disable password ageing)
  6. How to Clone Linux disk partition over network using dd
  7. CentOS / RHEL : How to find if a network port is open or not?
  8. CentOS / RHEL 6,7 : How to increase system log message verbosity (rsyslogd)
  9. How to enable NFS debug logging using rpcdebug
  10. How to Check the Size of the Yum Channels in Oracle Linux

You May Also Like

Primary Sidebar

Recent Posts

  • How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  • How to Capture More Logs in /var/log/dmesg for CentOS/RHEL
  • Unable to Start RDMA Services on CentOS/RHEL 7
  • How to rename a KVM VM with virsh
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary