Sunday, December 1, 2013

How to restore LVM

Using the command “vgcfgrestore” we can recover deleted LVM partitions. Linux keeps the backup copies of lvm configuration  in the /etc/lvm/archive directory. In my scenario I have deleted 10GB lvm partition, follow the below steps to recover the LVM partition :

Step:1 First find the backed up configurations of Volume Group (my-vg)


Synatx :

# vgcfgrestore --list   < Volume-Group-Name >
# vgcfgrestore --list my-vg
recover-lvm-partition

As you can see in the above example correct configuration are backed up , in my case “my-vg_00002-692643462.vg” is correct file throug which I will recover my lvm partitions.

Step:2 Now recover the LVM partition using vgcfgrestore and archive file

Syntax

# vgcfgrestore -f /etc/lvm/archive/

# vgcfgrestore -f /etc/lvm/archive/my-vg_00002-692643462.vg  my-vg

Ouptput would be : “Restored volume group my-vg”

Now we can mount lvm partition and check whether data is there or not.