If only the LVM metadata has been modified and the actual filesystem data has been left in-tact (meaning no process has caused any modification) and you have an available config from archive or backup then you
might be able to recover the LV by using
vgcfgrestore. Consult the man page for its use.
I've used this to "repair" corrupt on-disk LVM metadata but never tried it after lv-, vg-, pvremove.
Hope this helps.
Edit 1
Ok, so you got me curious.
A quick run-down of what I did and my results.
presented a ~20GB iscsi target to my system (sdd)
created single LinuxLVM primary partition sdd1
Code:
pvcreate /dev/sdd1
vgcreate testVG /dev/sdd1
lvcreate -l 100%VG -n testlV /dev/testVG
mke2fs -j /dev/testVG/testLV
mount /dev/testVG/testLV /mnt/test
cp /tmp/lvm.tgz /mnt/test/
umount /mnt/test
lvremove /dev/testVG/testLV
vgremove /dev/testVG
pvremove /dev/sdd1
pvcreate /dev/sdd1
vgcreate /dev/test2VG
lvcreate -l 100%VG -n test2LV /dev/test2VG
mount /dev/test2VG/test2LV /mnt/test
get the same fs error you are seeing
Code:
lvremove /dev/test2VG/test2LV
vgremove /dev/test2VG
pvremove /dev/sdd1
back to a partition (sdd1) with no LVM metadata on it
at this point i reviewed the testVG_00*.vg in /etc/lvm/archive to find the one that has the correct information that i want/need.
mine happened to be "testVG_00002.vg", yours may (and will likely) be different.
grab the pv uuid from there for the next command
Code:
pvcreate --restorefile /etc/lvm/archive/testVG_00002.vg --uuid N9iohj-6Rhd-Tv6S-8Wo9-NtnZ-dpj3-JVcF0G /dev/sdd1
proceeding, restore the vg metadata, confirm the vg info, activate the lv, and attempt mount
Code:
vgcfgrestore -f /etc/lvm/archive/testVG_00002.vg -v testVG
vgdisplay -v /dev/testVG
vgchange -ay /dev/testVG
mount /dev/testVG/testLV /mnt/test
mount fails again with your error
run an fsck on it (i used ext3 for my fs)
Code:
e2fsck /dev/testVG/testLV
you will in all likely-hood encounter "problems" with the filesystem, i said
yes to all questions to fix or correct a problem;
ran an fsck a 2nd time, came back clean
Code:
#mount /dev/testVG/testLV /mnt/test
#sha1sum /mnt/test/lvm.tgz /tmp/lvm.tgz
a73297ecb368a1b0aeea98b4f39c37363fd7f49f /mnt/test/lvm.tgz
a73297ecb368a1b0aeea98b4f39c37363fd7f49f /tmp/lvm.tgz
the file on the testVG that i just restored matches the original when output compared of sha1sum of the two files.
I can only hope you are as successful.
Hope this helps even more.
