udev
Rulesudev
is one of those pieces of Linux
that is fairly well
documented and not very well understood. This note isn't intended as
a general introduction to writing udev
rules, but, rather, a brief
introduction to the topic by way of specific example.
udev
?There are many clever uses for udev
documented on the Web, but
the most common use is to ensure that when you connect a device
- disk, tape, usb thumbdrive, camera... whatever - to a Linux
system, that device shows up with the same name every time.
Original Unix
derivatives had a static tree of devices the system
could support. This was encoded in the /dev
file tree hierarchy.
This was pretty inflexible in the face of devices being added- and
removed- from the system as it ran. For this reason, modern device
handling in Linux
and most other Unix
derivatives is
dynamic - the content of /dev
changes to reflect the actual
state of the system as things get connected or disconnected. (Exactly
how this is done is outside the purpose of this document, but if you
care, investigate the Linux /sys
filesystem works.)
While the example below is "cooked", it is very much rooted in real
world udev
application. We want to do the following things:
- Make sure that a particular disk always shows up under the same name under
/dev
no matter how many disks have been connected before it. We do that by uniquely identifying a disk and then creating a symbolic link to it that never changes.- Change the user and group ownership of that disk to something other than the default of
root:disk
.- Create a corresponding "raw" character device under
/dev/raw
. This is something you commonly see on database servers and it's suffiently useful that's it's worth mentioning here.
udev
Rules Live?Tim Daneliuk - tundra@tundraware.com
Comments and/or improvements welcome!
$Id: Deconstructing_Linux_udev_Rules.rst,v 1.101 2013/10/31 21:40:42 tundra Exp $
You can find the latest version of this document at:
http://www.tundraware.com/TechnicalNotes/Deconstructing-Linux-udev-Rules