Restoring deleted/resized logical volume

calm_downCalm yourself down

Congratulations, you managed to accidentaly remove useful logical volume!
No worries! Calm down, it’s all fine, we’ll get it back in few simple steps. Luckily, LVM archives all removed logical volumes when you make lvremove. In order to get it back we can use LVM’s native commands. All we have to do, is find which logical volume file to restore.


Find correct volume

Okay, first go to /etc/lvm/archive. Make sure you find your volume group name first, then find specific increment of your deleted logical volume. In order to verify if this is correct .vg file, you can check head of this file:

vs001 /etc/lvm/archive $ head -n 10 VG_00013.vg
# Generated by LVM2 version 2.02.54(1) (2009-10-26): Fri Jun 14 16:03:11 2013

contents = "Text Format Volume Group"
version = 1

description = "Created *before* executing 'lvremove /dev/VG/LV_NTP'"

If you look closely there is this lvremove /dev/VG/LV_NTP which is my command I used to delete my logical volume accidentally. There can be other descriptions also, for example, If you resized, shrinked, or any way otherwise modify your logical volume with LVM commands. You can recover any of that.

Restoration

Let’s test our restoration of logical volume first:

vgcfgrestore VG --test -f /etc/lvm/archive/VG_00013.vg
Test mode: Metadata will NOT be updated.
Restored volume group VG

Now that you see this would work, run same command again, but without –test parameter. You should see:

Restored volume group VG

Type lvscan and verify you see your Logical Volume. If it’s listed as inactive state, just change it back to active with command: lvchange -a y /dev/VG/LV_NTP

Comments

  1. By kristjan

    Reply

  2. Reply

  3. By Alen

    Reply

  4. By some admin

    Reply

  5. By Nina Šegula

    Reply

    • Reply

      • By dwt

Leave a Reply

help-hint.png
Purpose of the commenting system is to share your experience. I encourage you to post feedback with your own suggestions, ideas or optimizations regarding the topic of a blog post. What commenting system isn't for, is asking questions about similar issues of yours and requesting support for it. Blog post is provided as is and I am not here to solve all your problems. Please bear that in mind and try to avoid posting such comments. I do take privilege to remove comment from my blog for any reason whatsoever. Usually I do it when I sense a comment was posted only for spam/seo reasons or is out of blog post's topic. Thank you for reading this, now you may continue :)
 

Your email address will not be published. Required fields are marked *