Use a physical disk /dev/sdb to create pv, then create vg(name is vg0) based on pv, and create lv(path is /dev/mapper/vg0-vol0) based on vg. After unplugging /dev/sdb and then plugging it back in, the disk path is found to be /dev/sdc. Use pvdisplay to view it, warning pv duplication. At this time I used lslbk and found that lv disappears. I have two questions I would like to ask:
- Why is the warning pv repeated, because the UUID of the device is the same, why can't lvm automatically recognize it as the same pv?
- After the device is hot-plugged, is there any way to automatically restore the status of pv, vg and lv without manually typing commands? I ran pvscan --cache and found that lv still disappeared.
syslog print:
Mar 11 09:37:10 node1 lvm[37591]: Request to update PV IryAsJ-zQsP-S4yR-1Tnp-eDxd-vkrA-3xkUTP in lvmetad gave response failed. Reason: Ignore duplicate PVMar 11 09:37:10 node1 lvm[37591]: WARNING: To avoid corruption, restart lvmetad (or disable with use_lvmetad=0).pvdisplay print:
WARNING: Not using lvmetad because duplicate PVs were found. WARNING: Use multipath or vgimportclone to resolve duplicate PVs? WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad. --- Physical volume --- PV Name /dev/sdc VG Name vg0 PV Size <7.28 TiB / not usable <1.34 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 1907721 Free PE 0 Allocated PE 1907721 PV UUID IryAsJ-zQsP-S4yR-1Tnp-eDxd-vkrA-3xkUTPvgdisplay print:
WARNING: Not using lvmetad because duplicate PVs were found. WARNING: Use multipath or vgimportclone to resolve duplicate PVs? WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad. --- Volume group --- VG Name vg0 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size <7.28 TiB PE Size 4.00 MiB Total PE 1907721 Alloc PE / Size 1907721 / <7.28 TiB Free PE / Size 0 / 0 VG UUID VfZfgd-TZYG-pIcH-7W5M-hR7z-Vohf-vtRfUTrun pvscan --cache and lvdisplay print:
--- Logical volume --- LV Path /dev/vg0/vol0 LV Name vol0 VG Name vg0 LV UUID Kp5t20-tcSw-KjuE-0G2n-rI02-ruIC-3eY7X6 LV Write Access read/write LV Creation host, time node1, 2021-03-11 10:28:46 +0800 LV Status available # open 0 LV Size <7.28 TiB Current LE 1907721 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:3