Jump to content

Udev: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
udev-ng was renamed to eudev
Line 37: Line 37:


*udev supports persistent device naming, which does not depend on, for example, the order in which the devices are plugged into the system. The default udev setup provides persistent names for storage devices. Any hard disk is recognized by its unique filesystem id, the name of the disk and the physical location on the hardware it is connected to.
*udev supports persistent device naming, which does not depend on, for example, the order in which the devices are plugged into the system. The default udev setup provides persistent names for storage devices. Any hard disk is recognized by its unique filesystem id, the name of the disk and the physical location on the hardware it is connected to.
*udev executes entirely in [[user space]], as opposed to devfs' [[kernel space]]. One consequence is that udev moved the naming policy out of the kernel and can run arbitrary programs to compose a name for the device from the device's properties, before the node is created.
*udev executes entirely in [[user space]], as opposed to devfs' [[kernel space]]. One consequence is that udev moved the naming policy out of the kernel and can run arbitrary programs to compose a name for the device from the device's properties, before the node is created. Apparently it's better to move code into user space where it's interruptible and runs with a lower priority. Of course, such a policy modificatoin never break things that used to work.


== Operation ==
== Operation ==

Revision as of 00:02, 20 November 2012

udev
Developer(s)Greg Kroah-Hartman and Kay Sievers
Initial releaseNovember 2003 (2003-11)
Repository
Operating systemLinux kernel
TypeDevice node
LicenseGPL v2
Websitewww.freedesktop.org/software/systemd/libudev/

udev is the device manager for the Linux kernel. Primarily, it manages device nodes in /dev. It is the successor of devfs and hotplug, which means that it handles the /dev directory and all user space actions when adding/removing devices, including firmware load.

History

udev was introduced in Linux 2.5.

The Linux kernel version 2.6.13 introduced or updated a new version of the uevent interface. A system using a new version of udev will not boot with kernels older than 2.6.13 unless udev is disabled and a traditional /dev directory is used for device access.

In April 2012, udev's source tree was merged into systemd.[1]

Overview

Unlike traditional Unix systems, where the device nodes in the /dev directory have been a static set of files, the Linux udev device manager dynamically provides only the nodes for the devices actually present on a system. Although devfs used to provide similar functionality, advocates of udev cited a number of reasons[2] for preferring its implementation over devfs:

  • udev supports persistent device naming, which does not depend on, for example, the order in which the devices are plugged into the system. The default udev setup provides persistent names for storage devices. Any hard disk is recognized by its unique filesystem id, the name of the disk and the physical location on the hardware it is connected to.
  • udev executes entirely in user space, as opposed to devfs' kernel space. One consequence is that udev moved the naming policy out of the kernel and can run arbitrary programs to compose a name for the device from the device's properties, before the node is created. Apparently it's better to move code into user space where it's interruptible and runs with a lower priority. Of course, such a policy modificatoin never break things that used to work.

Operation

udev is a generic kernel device manager. It runs as a daemon on a Linux system and listens (via netlink socket) to uevents the kernel sends out if a new device is initialized or a device is removed from the system. The system provides a set of rules that match against exported values of the event and properties of the discovered device. A matching rule will possibly name and create a device node and run configured programs to set-up and configure the device.

udev rules can match on properties like the kernel subsystem, the kernel device name, the physical location of the device, or properties like the device's serial number. Rules can also request information from external programs to name a device or specify a custom name that will always be the same, regardless of the order devices are discovered by the system.

In the past a common way to use udev on Linux systems was to let it send events through a socket to HAL, which would perform further device-specific actions. For example, HAL would notify other software running on the system that the new hardware had arrived by issuing a broadcast message on the D-Bus IPC system to all interested processes. In this way, desktops such as GNOME or K Desktop Environment 3 could open a file browser to newly attached USB flash drives and SD cards.[3]

By the middle of 2011 HAL had been deprecated by most Linux distributions as well as by the KDE, GNOME[4] and XFCE[5] desktop environments, among others. The functionality previously embodied in HAL has been integrated into udev itself, or moved to separate software such as udisks and upower.

Architecture

The system is divided into three parts:

  • The library libudev, that allows access to device information.
  • The daemon udevd, in user space, that manages the virtual /dev.
  • The administrative command udevadm for diagnostics.

The system gets calls from the kernel via netlink socket. Earlier versions used hotplug, adding a link to themselves in /etc/hotplug.d/default with this purpose.

Authors

udev was developed by Greg Kroah-Hartman and Kay Sievers, with much help from Dan Stekloff, among others.

See also

  • devd – Device state change daemon for FreeBSD.
  • eudev - A version of udev forked by Gentoo developers free of systemd.

References

  1. ^ Sievers, Kay, "Commit importing udev into systemd", systemd, retrieved 25 May 2012
  2. ^ Greg Kroah-Hartman. "udev and devfs - The final word" (Plain text). Retrieved 2008-01-24.
  3. ^ "Dynamic Device Management in Udev" (PDF). Linux Magazine. 2006-10-01. Retrieved 2008-07-14.
  4. ^ "HALRemoval". 2011-06-28. Retrieved 2011-09-13.
  5. ^ "Thunar-volman and the deprecation of HAL in Xfce". 2010-01-17. Retrieved 2011-09-13.