Red Hat Training

A Red Hat training course is available for RHEL 8

Chapter 13. Limiting LVM device visibility and usage

You can limit the devices that are visible and usable to Logical Volume Manager (LVM) by controlling the devices that LVM can scan.

To adjust the configuration of LVM device scanning, edit the LVM device filter settings in the /etc/lvm/lvm.conf file. The filters in the lvm.conf file consist of a series of simple regular expressions. The system applies these expressions to each device name in the /dev directory to decide whether to accept or reject each detected block device.

13.1. The LVM device filter

The Logical Volume Manager (LVM) device filter is a list of device name patterns.

Patterns are regular expressions delimited by any character and preceded by a for accepting, or r for rejecting. The first regular expression in the list that matches a device determines if LVM accepts or rejects (ignores) a specific device. A device can have several names through symlinks. If the filter accepts any one of those device names, LVM uses the device. LVM also accepts devices that do not match any patterns.

The default device filter accepts all devices on the system. An ideal user configured device filter accepts one or more patterns and rejects everything else. For example, in such cases, the pattern list can end with r|.*|.

You can find the LVM devices filter configuration in the devices/filter and devices/global_filter fields in the lvm.conf file.

13.1.1. Additional resources

  • lvm.conf(5) man page

13.1.2. Examples of LVM device filter configurations

The list below shows filter configurations that control which devices LVM scans and can later use. Configure the device filter in the lvm.conf file.

  • The following is the default filter configuration, which scans all devices:

    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 Integrated Development Environment (IDE) devices and removes all other block devices:

    filter = [ "a|loop|", "a|/dev/hd.*|", "r|.*|" ]
  • The following filter adds only partition 8 on the first IDE drive and removes all other block devices:

    filter = [ "a|^/dev/hda8$|", "r|.*|" ]

Additional resources

  • lvm.conf(5) man page