Chapitre 10. 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.

Use LVM commands to control LVM device scanning. LVM commands interact with a file called the system.devices file, which lists the visible and usable devices. This feature is enabled by default in Red Hat Enterprise Linux 9.

If you disable the devices file feature, the LVM device filter is enabled automatically.

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.

10.1. The LVM devices file

The Logical Volume Manager (LVM) system.devices file controls device visibility and usability to LVM. You can find the devices file in the /etc/lvm/devices/ directory. Use LVM commands to manage the devices file. Do not directly edit the system.devices file.

By default, the system.devices file feature is enabled in Red Hat Enterprise Linux 9. When active, it replaces the LVM device filter. To enable the LVM device filter, disable the system.devices file. For more information see Disabling the system.devices file.

10.1.2. Adding devices to the system.devices file

To use devices with the Logical Volume Manager (LVM), the system.devices file must contain a list of the device IDs, otherwise LVM ignores them. The operating system (OS) installer adds devices to the system.devices file during installation. A newly installed system includes the root device into the devices file automatically. Any Physical Volumes (PV) attached to the system during OS installation are also included into the devices file. You can also specifically add devices to the devices file. LVM detects and uses only the list of devices stored in the devices file.

Procédure

Add devices to the system.devices file by using one of the following methods:

  • Add devices by including their names to the devices file:

    $ lvmdevices --adddev <device_name>
    Copy to Clipboard Toggle word wrap
  • Add all devices in a Volume Group (VG) to the devices file:

    $ vgimportdevices <vg_name>
    Copy to Clipboard Toggle word wrap
  • Add all devices in all visible VGs to the devices file:

    $ vgimportdevices --all
    Copy to Clipboard Toggle word wrap

To implicitly include new devices into the system.devices file, use one of the following commands:

  • Use the pvcreate command to initialize a new device:

    $ pvcreate <device_name>
    Copy to Clipboard Toggle word wrap
    • This action automatically adds the new Physical Volume (PV) to the system.devices file.
  • Initialize new devices and add the new device arguments to the devices file automatically:

    $ vgcreate <vg_name> <device_names>
    Copy to Clipboard Toggle word wrap
    • Replace <vg_name> with the name of the VG, from which you want to add devices.
    • Replace <device_names> with a space-separated list of the devices you want to add.
  • Use the vgextend command to initialize new devices:

    $ vgextend <vg_name> <device_names>
    Copy to Clipboard Toggle word wrap
    • Replace <vg_name> with the name of the VG, from which you want to add devices.
    • Replace <device_names> with the names of the devices you want to add.
    • This adds the new device arguments to the devices file automatically.

Vérification

Use the following verification steps only in case you need to explicitly add new devices to the system.devices file.

  • Display the system.devices file, to check the list of devices:

    $ cat /etc/lvm/devices/system.devices
    Copy to Clipboard Toggle word wrap
  • Update the system.devices file to match most recent device information:

    $ lvmdevices --update
    Copy to Clipboard Toggle word wrap

10.1.3. Removing devices from the system.devices file

Remove a device to prevent the Logical Volume Manager (LVM) from detecting or using that device.

Procédure

  • Remove a device by using one of the following methods depending on the information you have about that device:

    • Remove a device by name:

      $ lvmdevices --deldev <device_name>
      Copy to Clipboard Toggle word wrap
    • Remove a device by the Physical Volume ID (PVID) of the device:

      $ lvmdevices --delpvid <PV_UUID>
      Copy to Clipboard Toggle word wrap

Vérification

Use the following verification steps only in case you need to explicitly remove a devices in the system.devices file.

  • Display the system.devices file to verify, that the deleted device no longer present:

    $ cat /etc/lvm/devices/system.devices
    Copy to Clipboard Toggle word wrap
  • Update the system.devices file to match most recent device information:

    $ lvmdevices --update
    Copy to Clipboard Toggle word wrap

10.1.4. Creating custom devices files

Logical Volume Manager (LVM) commands use the default system.devices file of the system. You can also create and use custom devices files by specifying the new file name in the LVM commands. Custom devices files are useful in cases when only certain applications need to use certain devices.

Procédure

  1. Create a custom devices file in the /etc/lvm/devices/ directory.
  2. Include the new devices file name in the LVM command:

    $ lvmdevices --devicesfile <devices_file_name>
    Copy to Clipboard Toggle word wrap
  3. Optional: Display the new devices file to verify that the name of the new device is present:

    $ cat /etc/lvm/devices/<devices_file_name>
    Copy to Clipboard Toggle word wrap

10.1.5. Accessing all devices on the system

You can enable Logical Volume Manager (LVM) to access and use all devices on the system, which overrides the restrictions caused by the devices listed in the system.devices file.

Procédure

  • Specify an empty devices file:

    $ lvmdevices --devicesfile ""
    Copy to Clipboard Toggle word wrap

10.1.6. Disabling the system.devices file

You can disable the system.devices file functionality. This action automatically enables the Logical Volume Manager (LVM) device filter.

Procédure

  1. Open the lvm.conf file.
  2. Set the following value in the devices section:
use_devicesfile=0
Copy to Clipboard Toggle word wrap
Important

If you remove the system.devices file, this action effectively disables it. This applies even if you enable the system.devices file in the lvm.conf configuration file by setting use_devicesfile=1 in the devices section. Disabling the devices file automatically enables the lvm.conf device filter.

Retour au début
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2025 Red Hat