Restoring a deleted LV partition

If you have accidentally a VPS from a server, the LV partitions for data and swap will have been deleted. Please follow the following steps to recover. We are assuming xen20 is the deleted VPS here.

1. Checking to see what partition is missing

Look inside the /etc/xen/xen?? configuration file to see what partitions are contained in the deleted VPS:

   disk = [ 'phy:/dev/mapper/lvm1-xen20,sda1,w','phy:/dev/mapper/lvm1-xen20swap,sda2,w' ]

As you can see here, /dev/mapper/lvm1-xen20 and /dev/mapper/lvm1-xen20swap

2. Check to see if the LVM has the LV partition

   # lvdisplay /dev/lvm1/xen20

If the partition is not present, you will need to restore from the LVM backup cfg.

3. Check in the LVM backup

    # grep xen20 /etc/lvm/archive/*

Find the most recent archive which has both xen20 and xen20swap. You will need to compare this file with /etc/lvm/lvm.conf to make sure the archive has all of the partitions from lvm.conf + the missing 2. If there are partitions which are in the lvm.conf that aren't in the archive, please create a new config file with the union of both files.

4. Restore the VG configuration

First test the restore run to make sure it is consistent:

    # vgcfgrestore lvm1 --test -f /etc/lvm/archive/lvm1_00125.vg

Then, once it completes without error, run the real thing

    # vgcfgrestore lvm1 -f /etc/lvm/archive/lvm1_00125.vg

5. Check that the partition is active

    # lvdisplay /dev/lvm1/xen20

If it is not active, then do step 6

6. Rescan and reactivate the missing partition

    # lvscan
    # lvmdiskscan
    # lvscan -D
    # vgchange -a y
    # lvscan -D

You should see partition active on the last command

7. Startup the VPS to ensure that is working again

    # xm create -c xen20

8. Everything should be good to go!

Editing this page means accepting its license.

Page last modified on April 22, 2009, at 01:55 PM EST