5.5. フィルターを使用した LVM デバイススキャンの制御
At startup, the
vgscan command is run to scan the block devices on the system looking for LVM labels, to determine which of them are physical volumes and to read the metadata and build up a list of volume groups. The names of the physical volumes are stored in the LVM cache file of each node in the system, /etc/lvm/cache/.cache. Subsequent commands may read that file to avoiding rescanning.
lvm.conf 設定ファイル内にフィルターを設定することにより、LVM がスキャンするデバイスを制御することができます。lvm.conf ファイル内のフィルターは、一連の簡単な正規表現で構成されており、/dev ディレクトリ内のデバイス名に適用されて、各ブロックデバイスを受理するか、拒否するかの決定をします。
以下の例では、LVM がスキャンするデバイスを制御するフィルターの使用を示しています。正規表現は完全なパス名に対して自由にマッチングされるため、これらの例の一部は、必ずしもベストプラクティスを示すものではないことに注意してください。例えば、
a/loop/ は a/.*loop.*/ と同等であり、/dev/solooperation/lvol1 と適合します。
以下のフィルターは、検出されたすべてのデバイスを追加します。設定ファイル内で設定されているフィルターはないため、これがデフォルトの動作です。
filter = [ "a/.*/" ]
filter = [ "a/.*/" ]
以下のフィルターは、ドライブにメディアが入っていない場合の遅延を回避するために cdrom デバイスを削除します。
filter = [ "r|/dev/cdrom|" ]
filter = [ "r|/dev/cdrom|" ]
以下のフィルターはすべてのループを追加して、すべての他のブロックデバイスを削除します。
filter = [ "a/loop.*/", "r/.*/" ]
filter = [ "a/loop.*/", "r/.*/" ]
以下のフィルターはすべてのループと IDE を追加して、すべての他のブロックデバイスを削除します。
filter =[ "a|loop.*|", "a|/dev/hd.*|", "r|.*|" ]
filter =[ "a|loop.*|", "a|/dev/hd.*|", "r|.*|" ]
以下のフィルターは 1 番目の IDE ドライブ上にパーティション 8 のみを追加して、他のすべてのブロックデバイスを削除します。
filter = [ "a|^/dev/hda8$|", "r/.*/" ]
filter = [ "a|^/dev/hda8$|", "r/.*/" ]
注記
When the
lvmetad daemon is running, the filter = setting in the /etc/lvm/lvm.conf file does not apply when you execute the pvscan --cache device command. To filter devices, you need to use the global_filter = setting. Devices that fail the global filter are not opened by LVM and are never scanned. You may need to use a global filter, for example, when you use LVM devices in VMs and you do not want the contents of the devices in the VMs to be scanned by the physical host.