Datasheet
“main” (Installation and Administration) — 2004/6/25 — 13:29 — page 324 — #350
i
i
i
i
i
i
i
i
Traditionally, device nodes were stored in the /dev directory on Linux
systems. There was a node for every possible type of device, regardless of
whether it actually existed in the system. The result was that this directory
took up a lot of space. The command devfs has brought a significant im-
provement, because now only devices that really exist are given a device
node in /dev.
udev introduces a new way of creating device nodes. It compares the in-
formation made available by sysfs with data provided by the user in the
form of rules. sysfs is a new file system in kernel 2.6. It provides basic in-
formation about devices connected to the system. sysfs is mounted under
/sys.
It is not absolutely necessary for the user to create rules. If a device is con-
nected, the appropriate device node is created. However, the rules intro-
duce the possibility of changing the names for the nodes. This offers the
convenience of replacing a cryptic device name with a name that is easy to
remember and also of having consistent device names where two devices
of the same type have been connected.
Unless otherwise specified, two printers are given the designations /dev/
lp0 and /dev/lp1. Which device is given which device node depends on
the order in which they are switched on. Another example is external mass
storage devices, such as USB hard disks. The udev command allows exact
device paths to be entered in /etc/fstab.
15.1 Creating Rules
Before udev creates device nodes under /dev, it reads the file /etc/
udev/udev.rules. The first rule that fits a device is used, even if other
rules would also apply. Comments are introduced with a hash sign (#).
Rules take the following form:
key, [key,...] NAME [, SYMLINK]
At least one key must be specified, as rules are assigned to devices on the
basis of these keys. It is also essential to specify a name, as the device node
that is created in /dev bears this name. The optional symlink parameter
allows nodes to be created in other places. A rule for a printer could thus
take the following form:
BUS="usb", SYSFS{serial}="12345", NAME="lp_hp", SYMLINK="printers/hp"
324 15.1. Creating Rules










