Note: This content is accessible to all versions of every browser. However, this browser may not support basic Web standards, preventing the display of our site's design details. We support the mission of the Web Standards Project in the campaign encouraging users to upgrade their browsers.
Friday, September 03, 2004 17:03 // SUCON'04, Technopark, Zurich, Switzerland // href
by Greg Koah-Hartmann
Most Unix systems have a device filesystem. So does Linux with devfs. There are three main problems with it.
The code is ugly and beyond repair
The namespace is not LFS compliant
The author of the code has out of the loop for about two years.
A new solution has to be found, as the state of the /dev tree without some automatic management is not tenable. In Debian for example there are 18'000 static entries in there. And on the other hand there are USB plug and play devices which tend to get a different device name every time they are plugged in.
The only thing udev can not do, is to detect a process trying to access a device node that does not exist and then load the relevant driver. This feature of devfs does not seem crutial though.
In the kernel 2.6 there are two main components which make a new and simple solution possible:
The kernel can call a program called |/sbin/hotplug| whenever new devices are connected to the system.
The sysfs filesystem (mounted under /sys) contains all information about devices known to the kernel.
Udev provies a small userspace daemon which manages the /dev tree. It can populate it with a small set of default devices like ttys at boot time and then go on to add all other devices known to the system. It is configurable via simple text file with rules about the naming of the devices. These rules can be pretty sophisticated. Usb devices can be identified according to their vendor or product string as well as through any other property they provide. It is even possible to make udev run an external program which examines the device and then decides how the /dev entry should be called.
All distributions have adopted udev for their linux 2,6 editions. There are some teething problems with distros not using the official udev helper scripts. The author himself maintains the gentoo package.
Udev has to be started VERY early in the boot process, so that other programs can access the devices. Depending on the setup it may be necessary to add udev to initrd. Volume managers and RAID setups are mentioned.
*
Content © by Tobias Oetiker