How to recover deleted LVM partitions in Centos and Centos like OS

Most system administrators have mistakenly delete LVM partitions but not all is lost, using the command 'vgcfgrestore' we can recover deleted LVM partitions. Linux keeps the backup copies of lvm configuration inside /etc/lvm/archive directory.


 vgcfgrestore --list  LVM-GROUP-NAME list all the metadata backups made by the lvm subsystem,  every time we add, delete or alter the configuration a backup is created

[root@localhost]# vgcfgrestore --list storage



File: /etc/lvm/archive/storage_00059-1279792267.vg
VG name: storage
Description: Created *before* executing '/sbin/lvremove -f /dev/storage/www-backup'
Backup Time: Thu May 1 01:25:14 2013

 


File: /etc/lvm/archive/storage_00062-473822267.vg
VG name: storage
Description: Created *before* executing '/sbin/lvcreate -L3G -s -n ns1-backup /dev/storage/ns1'
Backup Time: Thu May 1 01:48:44 2013


File: /etc/lvm/archive/storage_00063-1908990772.vg
VG name: storage
Description: Created *before* executing '/sbin/lvremove -f /dev/storage/ns1-backup'
Backup Time: Thu May 1 01:53:06 2013



File: /etc/lvm/archive/storage_00065-149387914.vg
VG name: storage
Description: Created *before* executing '/sbin/lvremove -f /dev/storage/www-backup'
Backup Time: Fri May 2 01:25:17 2013

 

 

File: /etc/lvm/archive/storage_00069-762515257.vg
VG name: storage
Description: Created *before* executing '/sbin/lvremove -f /dev/storage/ns1-backup'
Backup Time: Fri May 2 01:52:48 2014

 

File: /etc/lvm/archive/storage_00071-258460846.vg
VG name: storage
Description: Created *before* executing '/sbin/lvremove -f /dev/storage/www-backup'
Backup Time: Sat May 3 01:25:16 2013

 

File: /etc/lvm/archive/storage_00074-717607964.vg

VG name: storage
Description: Created *before* executing '/sbin/lvcreate -L3G -s -n ns1-backup /dev/storage/ns1'
Backup Time: Sat May 3 01:48:34 2013


File: /etc/lvm/archive/storage_00075-510499646.vg
VG name: storage
Description: Created *before* executing '/sbin/lvremove -f /dev/storage/ns1-backup'
Backup Time: Sat May 3 01:52:46 2013

 

File: /etc/lvm/archive/storage_00075-710999646.vg

VG name: storage
Description: Created *before* executing '/sbin/lvremove -f /dev/storage/ns1'
Backup Time: Sat May 3 10:14:04 2013

To restore the LVM metadata to its state  *before* executing '/sbin/lvremove -f /dev/storage/ns1' on  Sat May 3 10:14:04 2013 we could execute:


[root@localhost]# vgcfgrestore -f /etc/lvm/archive/storage_00075-710999646.vg storage
[root@localhost]# lvchange -a y /dev/storage/ns1

Here we can see the partition has been recovered  /dev/storage/ns1

[root@localhost]# lvdisplay /dev/storage/ns1
--- Logical volume ---
LV Path /dev/storage/ns1
LV Name ns1
VG Name storage
LV UUID Elqx0f-EB4y-O2LJ-BnJ1-Zokp-rd5q-DHsdP7
LV Write Access read/write
LV Creation host, time bk1.servervirto.com, 2014-04-22 16:54:12 -0400
LV Status available
# open 0
LV Size 10.00 GiB
Current LE 320
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2

 



  • Email, SSL
  • 30 Users Found This Useful
Was this answer helpful?

Related Articles

Doing your backups with rsync

A very complete program for doing backups is rsync. What makes rsync ideal is its ...

How to configure postfix and dovecot in Centos 6

How to Postfix , Dovecot   (CentOS 6.x)  Install required software postfix,...