Wednesday, August 17, 2011

Recover LVM from Corrupted physical volume

I had Volume Group /dev/vg1 that consist two physical volumes /dev/sdb1 and /dev/sdc1 . One of physical volume /dev/sdc1, corrupted due to disk problem , now the challenge was to recover LVM. I decided to use pvremove command, in following way

root#pvremove /dev/sdc1

Above command displayed error couldn't find device uuid 'xxxxxxx'

Then issue tried forcefully

root#pvremove -ff /dev/sdc1

After some warning, it removed that physical volume.

Then i issued pvdisplay command


This display message ' Couldn't find device with uuid xxxxxx'

Now what you need to do is to create a physical volume with new disk with missing uuid .

For that following command can be used

root# pvcreate --uuid=xxxxxx /dev/sdd1 --restorefile=/etc/lvm/archive/

Where /dev/sdd1 is new hard disk in replace of /dev/sdc1

Then restore the vg metadata with following command

root# vgcfgrestore -f /etc/lvm/archive/ tvg0

Note: check archive of vg in /etc/lvm/archive