You are not logged in.
Hi,
I have had a problem with LVM recently which caused me to lose data. I am just curious if I could have prevented that (and if I should file a bug report), so I tried to reproduce it in a virtual machine.
The problem is as follows:
Assume I have 2 PVs, let's call them pv1 and pv2 (actually /dev/sda and /dev/sdb, for example)
I have one VG spanning these two, called vg1.
there are three LVs, lv1 and lv2 sitting on pv1 and lv3 on pv2.
Now the machine boots without pv2 attached to it. I can still access lv1 and lv2 and if at some later point pv2 is accessible again, I can also access lv3.
But while pv2 is not accessible, I remove lv2. lvremove complies without any warning.
If I now reattach pv2, the two PVs have different versions of the metadata of vg1. A call to "pvs" gives the attributes "a--" for pv1 and "a-m" for pv2.
Is there some way to reunite these two PVs and keep lv1 and lv3?
I tried the following:
# vgsplit vg1 vg2 pv2
Cannot change VG vg1 while PVs are missing
Consider vgreduce --removemissing
# vgreduce --removemissing vg1
WARNING: Partial LV lv3 needs to be repaired or removed.
There are still partial LVs in VG vg1
To remove them unconditionally use: vgreduce --removemising --force
Proceeding to remove empty missing PVs.
If I then use "--removemissing --force", lv3 gets removed.
If I do not remove anything and boot two systems, one with pv1 and one with pv2, each can see one intact LV. In each of them I could say "vgreduce --removemissing --force" to get a consistent VG. But even if I rename one of them to vg2 and then again boot a system with both pvs attached, it does not show both of them (I assume some UID is the same). Otherwise I could have tried to then do "vgmerge".
Does anyone have an idea how to fix this situation? I guess one thing might be to file a bug report that any change of metadata on an incomplete VG should be refused unless forced. But is there some way to come back from the situation "I deleted a logical volume while a physical volume was missing and now the metadata is different"?
Thanks for any insights!
Edit: It seems that "vgcfgbackup", followed by manually removing the "Missing" tag from /etc/lvm/backup/vg1 followed by "vgcfgrestore" does the trick. Seems quite dirty if you ask me. So the question becomes: is there a better way?
Last edited by viktordick (2016-06-16 08:21:51)
Offline