<< Prev. Page: Linux Device Hot plugging

udev tool

It automatically detects devices added or removed from system and generates device files for them in the /etc/dev directory. The name of the device files reflects their task like Printer device files begin with lp for ‘line print.' If more than one printer connected to the system, the number is attached after the prefix ‘lp', like lp0, lp1, lp2. The terminal device files begin with ‘tty' for ‘teletype' like tty0, tty1, tty2, and so on.

Each time the system boots, it invokes /sbin/udevstart which runs udev  and create kernel devices making device files in the ‘dev' directory. udev uses a set of rules located in the /etc/udev/rules.d file to direct the generation of device files, including any corresponding symbolic links like /dev/cdrom. The udev keeps track of currently installed devices. The rules files have ‘.rules' extension. Their name starts with numbers to establish priority. They are categorized into three general categories: names, permissions/ownership, and symbolic links.

On Red Hat, Fedora and similar distributions categories included in '50-udev.rules' primary rules file. And on Ubuntu or Debian included in '20-names.rules, 40-permissions.rules and 60-symlink.rules'. For specialized devices its 60-rules-libsane for scanners, 60-rules-libmtp for music players, 60-pcmcia.rules for PCMCIA devices, and 90-alsa.rules for a Sound driver.

Each device interface has a corresponding sysfs file, containing attributes like serial number, device major and minor numbers, used to identify the device. These attributes are used as keys in the udev rules to create a device interface in the /dev directory which gets listed in udev database with permissions specified in the udev permission rules. The changes manually done get lost with a system reboots.

Once the device file created, it runs the program:

udev Configuration


It contains global options such as:

  • udev_root: location of the device files directory set to official device directory /dev on Linux systems and is never changed.
  • udev_rules files: specify the location of rules files used to generate the device files
  • udev_log: enables them to turn ‘logging' on or off
  • udev_permissions: specifies the permission files location that holds permissions applied to specific devices
  • default_mode, default_owner and default_group: to set defaults
  • the location of udev database, the defaults for device permissions, owner and group, and the location of udev rules files.

HAL: It provides information about device files and manages the configuration for removable devices like file systems for USB, readers, cameras and CD-ROMs. Uses a sysfs file system to manage removable device files as needed.

  • /etc/hal: Configuration directory
  • /etc/hal/fdi: The HAL system administrator's device information files
  • /usr/share/hal/fdi: The device information for configuring HAL information support and policies