About UDEV



 

 


The udev program is designed to simplify the chaos that had overtaken the /dev directory with huge numbers of mostly unneeded devices. Understanding how udev works is key to dealing with devices, especially hotplug devices and how they can be managed.

/dev chaos

The /dev/directory has always been the location for the device files in all Unix and Linux operating systems. Note that device files are not the same as device drivers. Each device file represents one actual or potential physical device connected to the host.

In the past, device files were created at the time the operating system was created. This meant that all possible devices that might ever be used on a system needed to be created in advance. In fact, tens of thousands of device files needed to be created to handle all of the possibilities. It became very difficult to determine which device file actually related to a specific physical device.

udev simplification

udev is designed to simplify this problem by creating at boot time entries in /dev only for those devices that actually currently exist or which have a high probability of actually existing on the host. This significantly reduces the number of device files required.

In addition, udev assigns names to devices when they are plugged into the system, such as USB storage and printers, and other non-USB types of devices as well. In fact, udev treats all devices as plug’n’pray, even at boot time. This makes dealing with devices consistent at all times.

udev also moves device naming out of kernel space and into user space.

Here is a link to a paper written by one of the authors of udev. It provides insight into the details of udev and how it is supposed to work. Note that udev has matured since the article was written and some things have changed, such as the udev rule location and structure.

Kernel Korner – udev — Persistent Naming in User Space by Greg Kroah-Hartman

One of the main consequences of using udev for persistent plug’n’pray naming is that it makes things much easier for the average non-technical user. This is a good thing in the long run, however there have been migration problems.

Naming rules

udev stores its default naming rules in files in the /usr/lib/udev/rules.d directory, and it’s local configuration files in the /etc/udev/rules.d directory. Each file contains a set of rules for a specific device type.

In earlier versions of udev, there were many local rule sets created, including a set for NIC naming. As each NIC was discovered by the kernel and renamed by udev for the very first time, a rule was added to the ruleset for the network device type. This was initially done to ensure consistency before names had changed from “ethX” to more consistent ones.

Now that udev has multiple consistent default rules for determining device names, especially for NICs, storing the specific rules for each device in local configuration files is not required to maintain that consistency.

Early Problems

Although udev is designed to provide persistent device naming, I found that there were some issues with this and devices such as multiple Network Interface Cards (NICs)  were renamed after upgrades from Fedora 11 to fedora 12 or from pre-udev releases of Fedora to post-udev releases. This was necessary to move from random device naming to consistent naming, but it did cause a few issues when upgrading.