blog.erben.sk Just another sysadmin blog

27Jul/100

Recovering deleted lvm volume

LVM is a logical volume manager for the Linux kernel; it manages disk drives and similar mass-storage devices, in particular large ones. The term "volume" refers to a disk drive or partition thereof.

Every LVM operation makes backup of lvm metadata. Metadata archive stored in directory /etc/lvm/archive/ in easily readable text files. Each operation creates own metadata backup file, with information when it was created. For example:


# Generated by LVM2 version 2.02.39 (2008-06-27): Fri Feb  5 21:15:12 2010

contents = "Text Format Volume Group"
version = 1

description = "Created *before* executing 'lvcreate -L4G -n test data'"

creation_host = "avenger.iwik.org"      # Linux avenger.iwik.org 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:48:10 UTC 2009 i686
creation_time = 1265400912      # Fri Feb  5 21:15:12 2010

data {
        id = "ypogpf-ONt1-36Jh-xXXp-a3UN-Pjyt-wLn1zx"
        seqno = 19
        status = ["RESIZEABLE", "READ", "WRITE"]
        extent_size = 8192              # 4 Megabytes
        max_lv = 0
        max_pv = 0

  physical_volumes {

                pv0 {
                        id = "5n3lo9-S52y-3rTQ-3rP5-zfEC-irkg-OSRL3n"
                        device = "/dev/md2"     # Hint only

                        status = ["ALLOCATABLE"]
                        dev_size = 1930081024   # 920.334 Gigabytes
                        pe_start = 384
                        pe_count = 235605       # 920.332 Gigabytes
                }
        }

        logical_volumes {

                home {
                        id = "hyh3yU-jXr7-FMLT-ZxNY-ci50-L5e6-IGC3aM"
                        status = ["READ", "WRITE", "VISIBLE"]
                        segment_count = 1

                        segment1 {
                                start_extent = 0
                                extent_count = 65280    # 255 Gigabytes

                                type = "striped"
                                stripe_count = 1        # linear

                                stripes = [
                                        "pv0", 0
                                ]
                        }
                }

                var {
                        id = "0iOAxf-DhPG-T1Pk-3Qr1-Sqy5-XsKz-KyyCvo"
                        status = ["READ", "WRITE", "VISIBLE"]
                        segment_count = 1

                        segment1 {
                                start_extent = 0
                                extent_count = 3840     # 15 Gigabytes

                                type = "striped"
                                stripe_count = 1        # linear

                                stripes = [
                                        "pv0", 153600
                                ]
                        }
                }
                ...
                }
        }
}

Using correct backup file, lvm configuration can be easily recovered using vgcfgrestore command. If you deleted logical volume(s) or volume group, you can easily recover them back.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.