Why use udev




















Device file names can change when disks are removed from the system due to failure. The solution to avoid this type of situation is to guarantee consistent names for devices through reboots. Udev rules determine how to identify devices and how to assign a name that is persistent through reboots or disk changes. When Udev receives a device event, it matches the configured rules against the device attributes in sysfs to identify the device.

Rules can also specify additional programs to run as part of device event handling. Udev rules files are located in the following directories:. Rules files need to have unique names. Files in the custom rules directory override files of the same name in the default rules directory. Rules files are sorted and processed in lexical order.

The following is a partial listing of rules files from the default and custom rules directories:. This rules file contains over 60 entries. The selected entries assist in describing the syntax of the rules files. Comments begin with a sign. Each non-commented line in a rules file consists of a list of one or more key-value pairs separated by a comma. Matches the subsystem of the device that is affected by an event. Tests if the specified file or path exists.

Specifies a value for the device property key. Specifies the group for a device file. Specifies a set of variables for the device property, depending on type :. Import a single property from the boot kernel command line.

For simple flags, udevd sets the value of the property to 1. Interpret the specified value as an index into the device database and import a single property, which must have already been set by an earlier event. Interpret the specified value as the name of a text file and import its contents, which must be in environmental key format. Interpret the specified value as a key-name filter and import the stored keys from the database entry for the parent device.

Run the specified value as an external program and imports its result, which must be in environmental key format. Specifies the permissions for a device file. Specifies the name of a device file. Specifies rule and device options. Specifies the owner for a device file. Specifies the name of a symbolic link to a device file.

Specifies the value of a device property. Specifies the major number of a device. Import a set of variables as device properties, depending on type :. Execute an external program specified as the assigned value and, if it returns successfully, import its output, which must be in environment key format.

Similar to " program ", but use one of the built-in programs rather than an external one. Import a text file specified as the assigned value, the content of which must be in environment key format. Import a single property specified as the assigned value from the current device database. This works only if the database is already populated by an earlier event. Import a single property from the kernel command line. For simple flags the value of the property is set to " 1 ". Import the stored keys from the parent device by reading the database entry of the parent device.

For details see RUN. The key is true if the import is successful, unless "! Specify the priority of the created symlinks. Devices with higher priorities overwrite existing symlinks of other devices. The default is 0. When " none ", no replacement is performed. Defaults to unset.

Apply the permissions specified in this rule to the static device node with the specified name. Static device node creation is performed by systemd-tmpfiles before systemd-udevd is started. The static nodes might not have a corresponding kernel device; they are used to trigger automatic kernel module loading when they are accessed. Watch the device node with inotify; when the node is closed after being opened for writing, a change uevent is synthesized.

Set the flag sticky bit on the udev database entry of the event device. Device properties are then kept in the database even when udevadm info --cleanup-db is called. This option can be useful in certain cases e. Device Mapper devices for persisting device state on the transition from initramfs.

Takes a log level name like " debug " or " info ", or a special value " reset ". When a log level name is specified, the maximum log level is changed to that level. When " reset " is set, then the previously specified log level is revoked. Defaults to the log level of the main process of systemd-udevd. This may be useful when debugging events for certain devices.

Note that the log level is applied when the line including this rule is processed. So, for debugging, it is recommended that this is specified at earlier place, e. The RUN substitutions are performed after all rules have been processed, right before the program is executed, allowing for the use of device properties set by earlier matching rules.

For all other fields, substitutions are performed while the individual rule is being processed. The available substitutions are:. The kernel number for this device. For example, " sda3 " has kernel number 3. The value of a sysfs attribute found at the device where all keys of the rule have matched.

If the attribute is a symlink, the last element of the symlink target is returned as the value. The current name of the device. If not changed by a rule, it is the name of the kernel device.



0コメント

  • 1000 / 1000