Kvm-Virtualization

LV 內的 KVM、libvirt 和 LV

  • March 1, 2020

我有一個執行 KVM+libvirt 的 Debian 伺服器。VM 磁碟是主機上的 LV。問題在於,如果我在來賓內部創建 LV,它們會在主機上遞歸檢測到,這會產生各種問題,例如無法調整大小或正確刪除 LV。

所以我添加了一個過濾規則/etc/lvm/lvm.conf,以排除掃描其他 LV 內的 LV:

filter = [ "r|/dev/dm-*|", "a|/dev/sd.*|" ]

現在我的問題是:如何讓 LVM 只重新掃描“真正的”VG 和 LV?我現在有這樣的錯誤:

# lvs
 WARNING: Device for PV 73C0Ma-sAYV-Aa10-pAHB-ZAZA-3QjH-Rk1eTS not found or rejected by a filter.
 WARNING: Device for PV fcEG5k-BLzO-dbAr-Yw8o-dPw2-1hAk-VyluvW not found or rejected by a filter.
 LV              VG              Attr       LSize    Pool Origin    Data%  Meta%  Move Log Cpy%Sync Convert
 HaProxy         data            -wi-ao----   20,00g                                                       
 backup          data            -wi-ao----    4,00t                                                       
 database        data            -wi-ao----   16,00g                                                       
 lvol0           data            swi-a-s---   16,07g      stone-web 70,43                                  
 stone-vtls      data            -wi-ao----    2,00t                                                       
 stone-web       data            owi-aos---   16,00g                                                       
 lv0             ftpstorage      -wi-----p-   10,00t                                                       

在這種情況下,最後一個 lv 實際上是來自 VM 的 LV,而不是來自主機…如何在不重新啟動主機的情況下擺脫它?

根據 pvscan 手冊頁和 RHEL 文件,以下內容應該可以工作:/etc/lvm/lvm.conf

global_filter = [ "r|/dev/dm-*|", "a|/dev/sd.*|" ]
pvscan --cache

https://www.systutorials.com/docs/linux/man/8-pvscan/

To prevent devices from being scanned by pvscan --cache,
add them to lvm.conf(5) devices/global_filter.
The devices/filter setting does not apply to system level
scanning. For more information, see:
   lvmconfig --withcomments devices/global_filter 

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/logical_volume_manager_administration/lvm_filters

引用自:https://serverfault.com/questions/1004809