[lug] udev and hotplug

Lee Woodworth blug-mail at duboulder.com
Sun Jun 12 21:10:41 MDT 2005


Just a note on what I know of hotplug/udev.

hotplug:
   There are two parts, the kernel facility which enables
   kernel events to be delivered to user space via the
   program named by the contents of /proc/sys/kernel/hotplug;
   and the actions taken by the user space program, typically
   /sbin/hotplug. The hotplug package installs the user space
   actions that /sbin/hotplug performs. On my system they are
   a series of related scripts residing in /etc/hotplug.

   Note that the kernel hotplug firmware loading is a sub-feature
   of hotplug support and only applies to devices that need firmware
   loaded into a device.

   On 2.6, hotplug only completely handles device change events
   post boot. Devices  that are plugged in at boot (cold plugged)
   do not always generate device change events. On gentoo,
   /etc/init.d/hotplug doesn't do anything and the coldplug package
   must be installed to handle devices connected at boot (e.g.
   usb scanners).

   Device drivers have to be coded to produce hotplug events. My
   experience so far has been that all the major bus/class drivers
   (eg. usb, ieee) do have hotplug support.

   hotplug is a framework for doing something when a device's state
   changes. The base scripts installed by the hotplug package
   install kernel modules and generate bus specific (e.g. usb, ieee)
   events for bus handling agents. The actions of the agents can
   be augmented by adding to /etc/hotplug and/or /etc/hotplug.d.
   Examples of packages that do this are udev and sane-backends.

udev:
   udev is built on kernel-level hotplug services. It does not require
   the user space features provided by the hotplug package, although
   things may be better with user-space hotplug also installed.

   udev does not do device driver loading. It depends on the kernel-
   level hotplug facilities for that.

   What udev is intended to do is manage /dev in user space. This includes
   creating nodes as other systems load kernel modules (e.g. hotplug or
   a manual modprobe), creating device aliases (/dev/loop0 for /dev/loop/0)
   as well as setting permissions on created nodes.

   My experience with a pure-udev + hotplug system is that the boot-time
   module loading works well as does hot plugging. For coldplug cases,
   once you know the options to pass to a manual modprobe of a module,
   adding the info to the place(s) where the init system will find it
   is straightforward (at least for gentoo).

   The device naming part has been mostly trouble free. Some drivers
   are recognized by the hotplug system, but not by udev. I have to
   create the device nodes for a mini-dv camcorder in rc.localstart.
   Some devices don't actually require a kernel module, they just need
   udev to set permissions on devices in /proc/bus/.... Newer USB-based
   scanners are accessed via libusb in sane-backends with udev setting
   the permissions so that the scanner group can access the device.
   udev-046 & 58 have a bug where the permissions are not set for the
   scanner. A patch to /etc/hotplug/usb.rc is required.

In general things work pretty well. It is nice having only 143 entries in
/dev instead of 6+ screenfuls (80x43). If I could safely disable the aliasing
of ttynn -> vc/nn and cvsnn -> vcc/nn, I could get it down to 62 entries.





More information about the LUG mailing list