Newer
Older
deconstructing_udev / Deconstructing_Linux_udev_Rules.rst
@tundra tundra on 31 Oct 2013 2 KB Edits and cleanup.
Deconstructing Linux ``udev`` Rules
===================================

``udev`` 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.


Why Bother With ``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 how the ``Linux /sys`` filesystem works.)


Our Example Problem
===================

While the example below is "cooked", it is very much rooted in real
world ``udev`` applications.  We want to do the following things:

  - Identify a specific disk no matter what name it was assigned
    name under ``/dev``.

  - Create a symbolic link to that disk so that - no matter
    what it's name under ``/dev/`` might be at the moment -
    the symbolic link is always the same.

  - Change the user and group ownership of that disk to something
    other than the default (``root:disk``).

  - Create a corresponding "raw" character device under ``/dev/raw``
    associated with our disk above.  This is something commonly
    seen on database servers and it's suffiently useful that's it's
    worth mentioning here.


Where Do ``udev`` Rules Live?
=============================


Our Example Rules
=================


Author
======

    Tim Daneliuk - tundra@tundraware.com

    Comments and/or improvements welcome!


Document Revision Information
=============================

``$Id: Deconstructing_Linux_udev_Rules.rst,v 1.103 2013/10/31 21:50:07 tundra Exp $``

You can find the latest version of this document at:

  http://www.tundraware.com/TechnicalNotes/Deconstructing-Linux-udev-Rules