I am on CentOS 5.5 and am running Xen. I have a large volume group that I create logical volumes on using lvcreate. Today I had a customer cancel her account, then change her mind about an hour later. Unfortunately I had already removed the LVM her Xen image resided on. (just using a standard lvremove ). There has been no other LVM activity on this disk since then (nothing else added or deleted). Is it possible to "undo" a lvremove, or recover logical volume? If so, how would I go about it?
Lvm – How to recover logical volume deleted with lvremove
lvm
Best Answer
LVM does backup it's metadata to
/etc/lvm/backup
and/etc/lvm/archive
. At the top of each file it will tell you the time/data when the file was generated so chances are you'll have a copy of the older metadata as it was before you deleted the LV. I believe the backup is automatic anytime the metadata changes.The following can be dangerous and destructive so be very careful and if possible have a full backup.
The command to restore these volumegroup metadata backups is
vgcfgrestore
. Make sure you make a current copy of the existing working configuration using thevgcfgbackup
command with the -f flag to specify a different file for the output so that you don't alter any files that are in the /etc/lvm/backup or /etc/lvm/archive folders. Make sure you diff the current configuration with the configuration you wish to restore to verify that the only changes you're about to apply are to recreate the recently deleted LV. Having a full backup of your data probably isn't a bad idea either. You may also want to consider contacting your Linux vendor for support/guidance if you're under a support contract before proceeding as I've never had to do this myself.Good luck.