<div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Mar 23, 2018 at 11:30 AM Gang He <<a href="mailto:ghe@suse.com">ghe@suse.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello List,<br>
<br>
Since I am new to LVM area, but I got a problem about LVM can't work normally after attaching disk volumes originally in a VG on another machine.<br>
Then, I sent this problem to the list, to see if we can get a fix or there has been a fix.<br>
The problem is very easy to reproduce,<br>
1) create two virtual machines(tb0307-nd1, tb0307-nd2), create two virtual disks.<br></blockquote><div><br></div><div>Do you mean 2 logical volumes on the host?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
2) attach two virtual disks to VM1(tb0307-nd1).<br></blockquote><div><br></div><div>Are you attaching the logical volumes created on the host to the VM?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
tb0307-nd1:/# lsblk<br>
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT<br>
sr0 11:0 1 4.3G 0 rom<br>
vda 254:0 0 40G 0 disk<br>
├─vda1 254:1 0 4G 0 part [SWAP]<br>
├─vda2 254:2 0 23.6G 0 part /<br>
└─vda3 254:3 0 12.4G 0 part /home<br>
vdb 254:16 0 40G 0 disk<br>
vdc 254:32 0 20G 0 disk <<= disk1<br>
vdd 254:48 0 20G 0 disk <<= disk2<br>
3) pvcreate two virtual disks, and add them to vg1.<br>
tb0307-nd1:/# pvcreate /dev/vdc<br>
Physical volume "/dev/vdc" successfully created.<br>
tb0307-nd1:/# pvcreate /dev/vdd<br>
Physical volume "/dev/vdd" successfully created.<br>
tb0307-nd1:/# pvs<br>
PV VG Fmt Attr PSize PFree<br>
/dev/vdc lvm2 --- 20.00g 20.00g<br>
/dev/vdd lvm2 --- 20.00g 20.00g<br>
tb0307-nd1:/# vgcreate vg1 /dev/vdc /dev/vdd<br>
4) disconnect two virtual disks from VM1, and attach disk1 to VM2(tb0307-nd2).<br></blockquote><div><br></div><div>If /dev/vdc and /dev/vdd are logical volumes on the host, lvm on the host</div><div>just scanned these lvs and discovered the metadata created within the VM.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
5) delete vg1, create vg2, and add disk1 to vg2.<br>
tb0307-nd2:~ # pvs<br>
WARNING: Device for PV t6gjHU-dtY4-th5O-A0mr-5OEC-R1ZK-TPQgIh not found or rejected by a filter.<br>
PV VG Fmt Attr PSize PFree<br>
/dev/vdc vg1 lvm2 a-- 20.00g 20.00g<br>
[unknown] vg1 lvm2 a-m 20.00g 20.00g<br>
tb0307-nd2:~ # pvremove /dev/vdc<br>
WARNING: Device for PV t6gjHU-dtY4-th5O-A0mr-5OEC-R1ZK-TPQgIh not found or rejected by a filter.<br>
PV /dev/vdc is used by VG vg1 so please use vgreduce first.<br>
(If you are certain you need pvremove, then confirm by using --force twice.)<br>
/dev/vdc: physical volume label not removed.<br>
tb0307-nd2:~ # vgreduce --removemissing vg1<br>
WARNING: Device for PV t6gjHU-dtY4-th5O-A0mr-5OEC-R1ZK-TPQgIh not found or rejected by a filter.<br>
Wrote out consistent volume group vg1.<br>
tb0307-nd2:~ # pvs<br>
PV VG Fmt Attr PSize PFree<br>
/dev/vdc vg1 lvm2 a-- 20.00g 20.00g<br>
tb0307-nd2:~ # vgremove vg1<br>
Volume group "vg1" successfully removed<br>
tb0307-nd2:~ # vgcreate vg2 /dev/vdc<br>
Volume group "vg2" successfully created<br>
tb0307-nd2:~ # vgs<br>
VG #PV #LV #SN Attr VSize VFree<br>
vg2 1 0 0 wz--n- 20.00g 20.00g<br>
tb0307-nd2:~ # pvs<br>
PV VG Fmt Attr PSize PFree<br>
/dev/vdc vg2 lvm2 a-- 20.00g 20.00g<br>
<br>
6) attach disk2 to VM2(tb0307-nd2), the vg on VM2 looks abnormal.<br>
tb0307-nd2:~ # pvs<br>
WARNING: Device for PV JJOL4H-kc0j-jyTD-LDwl-71FZ-dHKM-YoFtNV not found or rejected by a filter.<br>
PV VG Fmt Attr PSize PFree<br>
/dev/vdc vg2 lvm2 a-- 20.00g 20.00g<br>
/dev/vdd vg1 lvm2 a-- 20.00g 20.00g<br>
[unknown] vg1 lvm2 a-m 20.00g 20.00g<br>
tb0307-nd2:~ # vgs<br>
WARNING: Device for PV JJOL4H-kc0j-jyTD-LDwl-71FZ-dHKM-YoFtNV not found or rejected by a filter.<br>
VG #PV #LV #SN Attr VSize VFree<br>
vg1 2 0 0 wz-pn- 39.99g 39.99g<br>
vg2 1 0 0 wz--n- 20.00g 20.00g<br>
<br>
7) reboot VM2, the result looks worse (vdc disk belongs to two vg).<br>
tb0307-nd2:/mnt/shared # pvs<br>
PV VG Fmt Attr PSize PFree<br>
/dev/vdc vg1 lvm2 a-- 20.00g 0<br>
/dev/vdc vg2 lvm2 a-- 20.00g 10.00g<br>
/dev/vdd vg1 lvm2 a-- 20.00g 9.99g<br>
<br>
<br>
It looks like LVM2 meta consistency problem? please help to take a look.<br></blockquote><div><br></div><div>If you want to attach logical volumes to VMs, you must make sure that these</div><div>volumes are not accessible to LVM on the host. A good way to achieve this is</div><div>to setup devices:filter in lvm.conf so LVM can access only the disks required</div><div>by the host (e.g. /dev/sda2).</div><div><br></div><div>Check this for more info on this problem:</div><div><a href="https://ovirt.org/blog/2017/12/lvm-configuration-the-easy-way/">https://ovirt.org/blog/2017/12/lvm-configuration-the-easy-way/</a><br></div><div><br></div><div>Nir</div></div></div></div>