Setting up lvm.conf filters

To prevent instance volumes connected to a computing node as network block devices (via FiberChannel or iSCSI) from being scanned by the node’s LVM system, lvm.conf filters must be configured.

If you do not configure filters, you may receive a :ref:` flush command error for multipath with the message “map in use” <flush_command_error>`.

Configuration is done by adding the filter parameter to the devices section of the file /etc/lvm/lvm.conf.

Since the lvm.conf file format is specific, you can use the augtool utility for correct or automated configuration. You can install the package with the command apt -y install augeas-tools.

An example of use with a preliminary check for the absence of configured filters:

[ $(augtool print /files/etc/lvm/lvm.conf/devices/dict/filter | wc -l) -gt 0 ] && echo "Filters aren't empty! Check manually!" || bash -c 'augtool -s set /files/etc/lvm
/lvm.conf/devices/dict/filter/list/1/str "a|/dev/sda$|" ; augtool set -s /files/etc/lvm/lvm.conf/devices/dict/filter/list/2/str "r|.*|"'

This example adds two values to the filter parameter:

a|/dev/sda$| - for the disk on which the host OS is installed, permission to scan,

r|.*| - for all other drives prohibited.

The file entry will look like this:

devices = {
...
...
filter = [ "a|/dev/sda$|", "r|.*|" ]
}

For a specific cloud installation and computing node configuration, the filters may be different. To select your circuit, please refer to the lvm2 documentation. The ultimate goal of configuring filters is to prevent the Compute Node’s LVM system from connecting virtual machines to the LV node. It should also be taken into account that when using multipath, the disks will be presented in the system multiple times: as scsi devices for each individual path and as a multipath device.

After setting up the filters, when you connect the disk to the machine, you will see the following entry in /var/log/syslog on the computing node:

lvm[15513]: pvscan[15513] /dev/mapper/36fc73fb10023e21aa52faf9b00000384-part5 excluded by filters: device is rejected
by filter config.