Chapter 15. Controlling LVM device scanning
You can control LVM device scanning by configuring filters in the /etc/lvm/lvm.conf
file. The filters in the lvm.conf
file consist of a series of simple regular expressions that get applied to the device names in the /dev
directory to decide whether to accept or reject each block device found.
15.1. The LVM device filter
LVM tools scan for devices in the /dev
directory and check every device there for LVM metadata. A filter in the /etc/lvm/lvm.conf
file controls which devices LVM scans.
The filter is a list of patterns that LVM applies to each device found by a scan of the /dev
directory, or the directory specified by the dir
keyword in the /etc/lvm/lvm.conf
file. Patterns are regular expressions delimited by any character and preceded by a
for accept or r
for reject. The first regular expression in the list that matches a device determines if LVM accepts or rejects (ignores) the device. LVM accepts devices that do not match any patterns.
The following is the default configuration of the filter, which scans all devices:
filter = [ "a/.*/" ]
15.2. Examples of LVM device filter configurations
The following examples show the use of filters to control which devices LVM scans.
Some of the examples presented here might unintentionally match extra devices on the system and might not represent recommended practice for your system. For example, a/loop/
is equivalent to a/.*loop.*/
and would match /dev/solooperation/lvol1
.
The following filter adds all discovered devices, which is the default behavior because no filter is configured in the configuration file:
filter = [ "a/.*/" ]
The following filter removes the
cdrom
device in order to avoid delays if the drive contains no media:filter = [ "r|^/dev/cdrom$|" ]
The following filter adds all loop devices and removes all other block devices:
filter = [ "a/loop/", "r/.*/" ]
The following filter adds all loop and IDE devices and removes all other block devices:
filter = [ "a|loop|", "a|/dev/hd.*|", "r|.*|" ]
The following filter adds just partition 8 on the first IDE drive and removes all other block devices:
filter = [ "a|^/dev/hda8$|", "r/.*/" ]
15.3. Applying an LVM device filter configuration
This procedure changes the configuration of the LVM device filter, which controls the devices that LVM scans.
Prerequisites
- Prepare the device filter pattern that you want to use.
Procedure
Test your device filter pattern without modifying the
/etc/lvm/lvm.conf
file.Use an LVM command with the
--config 'devices{ filter = [ your device filter pattern ] }'
option. For example:# lvs --config 'devices{ filter = [ "a|/dev/emcpower.*|", "r|.*|" ] }'
-
Edit the
filter
option in the/etc/lvm/lvm.conf
configuration file to use your new device filter pattern. Check that no physical volumes or volume groups that you want to use are missing with the new configuration:
# pvscan
# vgscan
Rebuild the
initramfs
file system so that LVM scans only the necessary devices upon reboot:# dracut --force --verbose