Este contenido no está disponible en el idioma seleccionado.
A.3. Device Mapper Support for the udev Device Manager
The primary role of the
udev device manager is to provide a dynamic way of setting up nodes in the /dev directory. The creation of these nodes is directed by the application of udev rules in user space. These rules are processed on udev events sent from the kernel directly as a result of adding, removing or changing particular devices. This provides a convenient and central mechanism for hotplugging support.
Besides creating the actual nodes, the
udev device manager is able to create symbolic links which you can name. This provides you the freedom to choose their own customized naming and directory structure in the/dev directory, if needed.
Each
udev event contains basic information about the device being processed, such as its name, the subsystem it belongs to, the device's type, its major and minor number used, and the type of the event. Given that, and having the possibility of accessing all the information found in the /sys directory that is also accessible within udev rules, you are able to utilize simple filters based on this information and run the rules conditionally based on this information.
The
udev device manager also provides a centralized way of setting up the nodes' permissions. You can easily add a customized set of rules to define the permissions for any device specified by any bit of information that is available while processing the event.
It is also possible to add program hooks in
udev rules directly. The udev device manager can call these programs to provide further processing that is needed to handle the event. Also, the program can export environment variables as a result of this processing. Any results given can be used further in the rules as a supplementary source of information.
Any software using the
udev library is able to receive and process udev events with all the information that is available, so the processing is not bound to the udev daemon only.
A.3.1. udev Integration with the Device Mapper Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
The Device Mapper provides direct support for
udev integration. This synchronizes the Device Mapper with all udev processing related to Device Mapper devices, including LVM devices. The synchronization is needed since the rule application in the udev daemon is a form of parallel processing with the program that is the source of the device's changes (such as dmsetup and LVM). Without this support, it was a common problem for a user to try to remove a device that was still open and processed by udev rules as a result of a previous change event; this was particularly common when there was a very short time between changes for that device.
Red Hat Enterprise Linux provides officially supported
udev rules for Device Mapper devices in general and for LVM as well. Table A.1, “udev Rules for Device-Mapper Devices” summarizes these rules, which are installed in /lib/udev/rules.d.
| Filename | Description | ||
|---|---|---|---|
10-dm.rules |
| ||
11-dm-lvm.rules |
| ||
13-dm-disk.rules | Contains rules to be applied for all Device Mapper devices in general and creates symlinks in the /dev/disk/by-id and the /dev/disk/by-uuid directories. | ||
95-dm-notify.rules | Contains the rule to notify the waiting process using libdevmapper (just like LVM and dmsetup). The notification is done after all previous rules are applied, to ensure any udev processing is complete. Notified process is then resumed. | ||
69-dm-lvm-metad.rules | Contains a hook to trigger an LVM scan on any newly appeared block device in the system and do any LVM autoactivation if possible. This supports the lvmetad daemon, which is set with use_lvmetad=1 in the lvm.conf file. The lvmetad daemon and autoactivation are not supported in a clustered environment. |
You can add additional customized permission rules by means of the
12-dm-permissions.rules file. This file is not installed in the /lib/udev/rules directory; it is found in the /usr/share/doc/device-mapper-version directory. The 12-dm-permissions.rules file is a template containing hints for how to set the permissions, based on some matching rules given as an example; the file contains examples for some common situations. You can edit this file and place it manually in the /etc/udev/rules.d directory where it will survive updates, so the settings will remain.
These rules set all basic variables that could be used by any other rules while processing the events.
The following variables are set in
10-dm.rules:
DM_NAME: Device Mapper device nameDM_UUID: Device Mapper device UUIDDM_SUSPENDED: the suspended state of Device Mapper deviceDM_UDEV_RULES_VSN:udevrules version (this is primarily for all other rules to check that previously mentioned variables are set directly by official Device Mapper rules)
The following variables are set in
11-dm-lvm.rules:
DM_LV_NAME: logical volume nameDM_VG_NAME: volume group nameDM_LV_LAYER: LVM layer name
All these variables can be used in the
12-dm-permissions.rules file to define a permission for specific Device Mapper devices, as documented in the 12-dm-permissions.rules file.
A.3.2. Commands and Interfaces that Support udev Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
Table A.2, “dmsetup Commands to Support udev” summarizes the
dmsetup commands that support udev integration.
| Command | Description |
|---|---|
dmsetup udevcomplete | Used to notify that udev has completed processing the rules and unlocks waiting process (called from within udev rules in 95-dm-notify.rules). |
dmsetup udevcomplete_all | Used for debugging purposes to manually unlock all waiting processes. |
dmsetup udevcookies | Used for debugging purposes, to show all existing cookies (system-wide semaphores). |
dmsetup udevcreatecookie | Used to create a cookie (semaphore) manually. This is useful to run more processes under one synchronization resource. |
dmsetup udevreleasecookie | Used to wait for all udev processing related to all processes put under that one synchronization cookie. |
The
dmsetup options that support udev integration are as follows.
--udevcookie- Needs to be defined for all
dmsetupprocesses we would like to add into audevtransaction. It is used in conjunction withudevcreatecookieandudevreleasecookie:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Besides using the--udevcookieoption, you can just export the variable into an environment of the process:Copy to Clipboard Copied! Toggle word wrap Toggle overflow --noudevrules- Disables
udevrules. Nodes/symlinks will be created bylibdevmapperitself (the old way). This option is for debugging purposes, ifudevdoes not work correctly. --noudevsync- Disables
udevsynchronization. This is also for debugging purposes.
For more information on the
dmsetup command and its options, see the dmsetup(8) man page.
The LVM commands support the following options that support
udev integration:
--noudevrules: as for thedmsetupcommand, disablesudevrules.--noudevsync: as for thedmsetupcommand, disablesudevsynchronization.
The
lvm.conf file includes the following options that support udev integration:
udev_rules: enables/disablesudev_rulesfor all LVM2 commands globally.udev_sync: enables/disablesudevsynchronization for all LVM commands globally.
For more information on the
lvm.conf file options, see the inline comments in the lvm.conf file.