udev History – What Does It Mean When UNIX Device Files Are Static?

historyudev

I've been reading up on udev. In the "overview" section, Wikipedia states that "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".

What does it mean when it says "static set of files"? Does it mean that there are always /dev files but they don't always point to a real device?

Best Answer

I assume you're referring to this paragraph:

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, Greg Kroah-Hartman cited a number of reasons3 for preferring its implementation over devfs:

From the 1st sentence they're referring to other Unix systems where the devices in /dev are statically created and persisted from reboot to reboot. Previous versions of Linux (think the 2.4 version of the Kernel) used to work this way too, newer versions no longer behave in this manner. Other Unixes typically include a common set of device files when you install them, and only rarely is it necessary to manually create additional ones.

In 2.4 you could use the mknod command to manually to create any necessary device files. For example:

$ mknod ./dev/random b 12 5

NOTE: This is stating create the /dev/random file descriptor, as a block device with major device number of 12 and a minor device number of 5.

Device files under /dev

The OP asked the following follow-up question regarding the overall functionality of the /dev directory. Here's his question:

Can you add details on the technical method used to persist device files across reboots? how are they physically stored on disk? did they need special filesystem support?

In researching this I figured I'd start with the Linux From Scratch project to get a basic idea of how /dev is managed in newer versions of the Linux kernel. I know that in the past (think Kernel versions 2.4 and before) the /dev directory was a static set of files that literally took up space on the HDD, but with the advent of udev and sysfs this was no longer the case.

Traditionally, these special files were created at install time by the distribution, using the mknod command. In recent years, Linux systems began using udev to manage these /dev files at runtime. For example, udev will create nodes when devices are detected and delete them when devices are removed (including hotplug devices at runtime). This way, the /dev directory contains (for the most part) only entries for devices which actually exist on the system at the current time, as opposed to devices which could exist.

So gone are the days of having to worry about your device files under /dev. This directory is now completely managed by udev and sysfs from reboot to reboot.

Additional udev & sysfs resources

References

Related Question