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.
You can control which devices LVM scans by setting up filters in the lvm.conf configuration file. The filters in the lvm.conf file consist of a series of simple regular expressions that get applied to the device names that are in the /dev directory to decide whether to accept or reject each block device found.
The following examples show the use of filters to control which devices LVM scans. Note that some of these examples do not necessarily represent best practice, as the regular expressions are matched freely against the complete pathname. For example, a/loop/ is equivalent to a/.*loop.*/ and would match /dev/solooperation/lvol1.
下面的过滤器添加所有找到的设备,这是配置文件中没有配置过滤器的默认行为:
filter = [ "a/.*/" ]
Copy to Clipboard Toggle word wrap
下面的过滤器会删除光驱以避免在驱动器中没有介质时造成延迟:
filter = [ "r|/dev/cdrom|" ]
Copy to Clipboard Toggle word wrap
下面的过滤器添加所有回路设备并删除其它块设备:
filter = [ "a/loop.*/", "r/.*/" ]
Copy to Clipboard Toggle word wrap
下面的过滤器添加所有回路设备和 IDE 设备,同时删除所有其它块设备:
filter =[ "a|loop.*|", "a|/dev/hd.*|", "r|.*|" ]
Copy to Clipboard Toggle word wrap
下面的过滤器只添加第一个 IDE 驱动器中的分区 8,同时删除所有其它块设备:
filter = [ "a|^/dev/hda8$|", "r/.*/" ]
Copy to Clipboard Toggle word wrap

注意

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.
For more information on the lvm.conf file, see 附录 B, LVM 配置文件 and the lvm.conf(5) man page.
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部