udev is pure crap.
For some reason, the kernel developers seem to like the "udev" system. For those of you who've been living under a rock for the past few years: udev is a pile of scripts that react to kernel hotplug events and will start setting up device nodes and go mount them, etc. While this is all probably very nice for users not very familiar with the system, it has one fatal flaw:
It removes the perfectly deterministic and reproducible boot characteristics of a Linux system, and replaces them with something that will work when you're there, but break the next time. According to murphy's law, that "next time" is obviously when you're on vacation, the guy with access to the data center ran under a bus and is in hospital, and the breakage introduced with udev somehow also broke the VPN to your router, so you can't even remotely powercycle the beast. Or so.
I don't like a system that starts playing with my device nodes. I have a static /dev, which does everything I need it to do; when I put a CD-ROM in the drive, I'll mount it myself, thank you. If I change something about my system configuration, I'm perfectly capable of modifying the configuration to match myself. I am perfectly happy with a system that will autoload kernel modules when I plug in some USB device, however, and there's nothing wrong with the ability to create some scripts that will set up stuff the way I want them to be.
Hotplug allows all of that. By using hotplug, a USB mouse Just Works(TM) when I plug it in. There are more things like that, which Just Work. A USB key is not one of them, nor is a CD-ROM. And that's a good thing; I don't want filesystems to be mounted at random just because someone got hold of my laptop for a while.
So don't use udev
, I hear you say. And, well, I'm not. But the
problem is that the kernel maintainers seem inclined to make it harder
and harder to do so. And eventually, the result will be that I'll have
to install a system which will break my boot sequence every other day
just to be able to have a mouse work two seconds after I plug it in.
Madness.
At first I didn't like udev, but after playing with a recent version and a 2.6.15 kernel, I really started to like it. I'm using 0.087-2 udev BTW.
It makes setting up usb flash devices on shared machines really simple. USB printers are also easier since you can create fixed names for them, as opposed to assuming they will always be lp0 and not lp1 (when usb hubs reset, that can change).
I have a machine with USB keyb, USB mouse, USB printer, USB scanner, USB CF reader, USB mp3 player, USB flash sticks, and USB camera, and udev has made life much easier. I can also see it being very beneficial for hot-swap SCSI drives.
If you need static devices, just put them in: /lib/udev/devices (need recent udev).
Following are some of my own notes made during my udev setup: * purpose - hotplug is an interface by which kernel launches a userspace program whenever a device (dis)appears on a bus. This program is then responsible for loading an appropriate driver. Hotplug is also a userspace set of scripts to interface to the kernel hotplug system. - udev is userspace dev filesystem daemon. Once a new hotplug device appears, it will create persistent names in /dev that can be used reliably (ex: to mount). Newer udev versions replace Hotplug user space tools. - systool is a userspace utility to show system (/sys) devices. Example: systool -v -b usb -
udevinfo -e
can be used to show current udev database - this information is not directly usable in creating rules (too broad) * installationapt-get install udev
apt-get install sysfsutils
apt-get install hotplug
# for kernel versions ~< 2.6.12/sbin/shutdown -r now
* fine tuning /etc/udev/rules.d/* contains mapping definitions between kernel devices and /dev names. These names are actually symlinks to device nodes. * creating rules (usb-storage example) 1. insert a usb storage device, kernel should display a message 2. lookup sys path for the device udevinfo -q path -n /dev/sdc this should return something like "/block/sdc" as an offset from /sys/ 3. lookup udev information udevinfo -a -p /sys/block/sdc it will display the leaf and parents of the requested device 4. create a rule matching this device ex: BUS=="scsi", SYSFS{model}=="USB2FlashStorage", KERNEL=="sd?1", NAME="%k", SYMLINK+="myflash" located on scsi bus, matching the model info, assigned first partition on a scsi disk device, use kernel device name in /dev and symlink to it using myflash name. More rules: BUS=="scsi", SYSFS{model}=="MassStorage Disc", SYSFS{vendor}=="iriver ", SYMLINK+="mp3" on scsi bus, matching model and vendor, symlink to device node using mp3. More rules: BUS=="usb", KERNEL=="sd*", SYMLINK+="autoflash%n" on usb bus, is a scsi disk device, add enumerated symlink autoflash%n pointing to it's device node. Notes: When matching SYSFS, all other SYSFS attributes have to match on the same tree level of udevinfo output. Udev allows matching a usb bus device which later becomes abstracted as a scsi disk device by specifing KERNEL=="sd*". KERNEL is evaluated on the leaf and the rest matches within a common parent level before usb becomes abstracted as a block scsi device. - Example: both of these rules will match the same device, one at scsi level and one at usb level. The device is a usb mp3 player that gets a scsi disk device node assigned to it: BUS=="scsi", SYSFS{model}=="MassStorage Disc", SYSFS{vendor}=="iriver ", KERNEL=="sd*", SYMLINK+="mp3" BUS=="usb", SYSFS{product}=="iriver Internet Audio Player IFP-899", KERNEL=="sd*", SYMLINK+="mp3" * testing rules:udevtest /block/sdc
- above does not need udev to be restarted. To finalize the changes, unplug the device, shutdown udev, start udev and plug the device in. Note: udevtest will not show creation of %n device name/symlinks. * usb mice & keyboards If one loads usbmouse kernel driver on top of usbhid, there can be problems using a mouse. usbhid driver alone should be used for accessing keyboards and mice. Typical symptom is a mouse that jumps around as if a wrong gpm/x11 driver was selected. To disable loading add usbmouse and usbkbd to /etc/hotplug/blacklist. Sometimes these drivers can be loaded in initrd, just rmmod them and rebuild the initrd image. * static device nodes to create static device nodes, place them in /lib/udev/devices, and they will be placed in tmpfs /dev on udevd's startup.