How to recover a LV after mirror failure
How to recover a LV after mirror failure.
Way 1 – If you don’t have another devide to recover the mirror
*** always remember to check /etc/lvm/backup directory. ***
Try to activate all lvs:
# vgchange -ay
you’ll receive some errors like this:
Couldn’t find device with uuid ‘4bpgtD-txaN-rL2o-Mlii-0zx3-aGJB-DMTxco‘.
you can try to activate the lv in read-only mode. For example to do a backup of files into the lv:
# lvchange -ay /dev/vg00/testlv –partial
# mount /dev/vg00/testlv /mountpoint
and them you have to umount, deactivate the lv and remove missing pvs:
# umount /mountpoint
#lvchange -an /dev/vg00/testlv
#vgreduce –removemissing –force vg00
check if that errors are gone:
[root@localhost test]# pvs
PV VG Fmt Attr PSize PFree
/dev/hdb vg00 lvm2 a- 2.00G 1.96G
[root@localhost test]#
activate the lv and be happy:
# lvchange -ay /dev/vg00/testlv
# mount /dev/vg00/testlv /mountpoint
Way 2 – If you have another device to recover the mirror
find the UUID for the physical volume that are missing:
[root@localhost lvm]# pvs
Couldn’t find device with uuid ‘Bm8kJh-GJjL-aYbr-HI3K-EqnX-xOJA-wX3NbD‘.
..
[root@localhost lvm]#
Look into the diretory /etc/lvm/archive for the last known valid archived LVM metadata for that volume group.
Use the –uuid and –restorefile arguments of the pvcreate command to restore the physical volume:
[root@localhost lvm]# pvcreate –uuid “Bm8kJh-GJjL-aYbr-HI3K-EqnX-xOJA-wX3NbD” –restorefile /etc/lvm/archive/vg00_00017.vg /dev/hdd
Couldn’t find device with uuid ‘Bm8kJh-GJjL-aYbr-HI3K-EqnX-xOJA-wX3NbD’.
Physical volume “/dev/hdd” successfully created[root@localhost lvm]#
Restore the VG configuration:
[root@localhost lvm]# vgcfgrestore vg00
Restored volume group vg00
[root@localhost lvm]#
Check if everything is ok:
[root@localhost test]# lvs -a -o +devices | grep testlv
testlv vg00 mwi-ao 32.00M 100.00 testlv_mimage_0(0),testlv_mimage_1(0)
[testlv_mimage_0] vg00 iwi-ao 32.00M /dev/hdb(0)
[testlv_mimage_1] vg00 iwi-ao 32.00M /dev/hdd(0)
[root@localhost test]#
Activate the volumes and mount:
[root@localhost test]# lvchange -ay /dev/vg00/testlv
[root@localhost test]# mount /dev/vg00/testlv /mountpoint
bye