Skip to content

udev: manage inserted devices

drinkcat edited this page Oct 30, 2013 · 2 revisions

udev performs rule-defined actions as a result of device events. For example, the kernel will assign an arbitrary device node, such as /dev/sdb, to an inserted ABC #3 USB thumb drive. The udev rule

KERNEL=="sd?", ATTRS{model}=="ABC MODEL 3", SYMLINK+="thumb", GROUP="lclusr"

sets the device's group to lclusr and creates a symlink (/dev/thumb) to it. See udev documentation (e.g. http://reactivated.net/writing_udev_rules.html) for more information.

Running a second udev daemon in the chroot

The udev daemon can be run inside a crouton chroot by including /etc/init.d/udev start in /etc/rc.local. However, this can cause conflicts, e.g. the default udev rules make crouton's audio fail. There's a better way..

Leverage on Chromium OS' udev daemon (recommended)

udev is already running in Chromium OS, and we can use it. To do so,

  • Put files containing (only) the rules you need in /etc/udev/rules.d in the chroot.

  • In /etc/rc.local, add the line

      cp /etc/udev/rules.d/*.rules /run/udev/rules.d
    

(/run/udev is bind-mounted to the appropriate Chromium OS directory.)

Note that user and group names specified in rules will be matched to the Chromium OS /etc/passwd and /etc/group files rather than the chroot's. The chroot's numerical values can be used instead, e.g. GROUP="1234" in the example above.