diff --git a/Deconstructing_Linux_udev_Rules.rst b/Deconstructing_Linux_udev_Rules.rst index ed7be62..808b732 100644 --- a/Deconstructing_Linux_udev_Rules.rst +++ b/Deconstructing_Linux_udev_Rules.rst @@ -6,6 +6,11 @@ a general introduction to writing ``udev`` rules, but, rather, a brief introduction to the topic by way of specific example. +.. NOTE:: The examples and descriptions below assume you + are running as ``root``. Most of the commands + described will either return nothing or will not + work at all unless you are ``root``. + Why Bother With ``udev``? ========================= @@ -121,47 +126,61 @@ - ``PROGRAM=="/sbin/scsi_id --whitelisted /dev/$name"`` - ``RESULT=="1ATA_VBOX_HARDDISK_VB5f712327-2bb4be0c"`` - ``SYMLINK+="my_fine-disk01"`` - - ``OWNER:="3009"`` - - ``GROUP:="421"`` - - ``MODE:="0600",`` + - ``"OWNER:="3009", GROUP:="421", MODE:="0600",`` - ``RUN=="/bin/raw /dev/raw/raw1 /dev/$name"`` Now, let's look at the second rule: - ``KERNEL=="raw1"`` - ``SYMLINK+="rmy_fine-disk01"`` - - ``OWNER:="3009"`` - - ``GROUP:="421"`` - - ``MODE:="0600"`` + - ``"OWNER:="3009", GROUP:="421", MODE:="0600"`` -Other Thoughts + +Final Thoughts ============== -Obviously, you'd have to have another pair of rules for each additional -disk you want to manage this way. Adding another disk would be a matter -of using ``scsi_id`` to get its ``wwid`` and for the ``RESULT`` field -of the first rule. You'd also have to change references to ``my_fine_disk01`` -and ``raw1``. +Obviously, you'd have to have another pair of rules for each +additional disk you want to manage this way. Adding another disk +would be a matter of using ``scsi_id`` to get its ``wwid`` for the +``RESULT`` field of the first rule. You'd also have to change any +references to ``my_fine_disk01`` and ``raw1``. For reasons that are not entirely clear (to me anyway), the ``raw`` command only knows how to create raw devices whose names begin with ``raw``, go figure. +Another way to get a unique ID for a device is to tail your system log +(``tail -f /var/log/messages`` or ``tail -f /var/log/syslog``) and +watch what happens when you plug your device into, say, a USB port. + +If you want to know all the attributes ``udev`` knows about a particular +device, use this, substituting your device for ``/dev/sdd`` :: + + udevadm info --query=all --name /dev/sdd 2>&1| less + +The output of this command can be helful in figuring out just which +attributes and values you need to get to a running rule. + +Finally, you can test your rules to see what is matching, again +substituting for ``/block/sdd``:: + + udevadm test /block/sdd 2>&1| less + Author ====== Tim Daneliuk - tundra@tundraware.com - Comments and/or improvements welcome! + Comments, corrections, clarifications, and/or improvements welcome! Document Revision Information ============================= -``$Id: Deconstructing_Linux_udev_Rules.rst,v 1.106 2013/10/31 22:44:17 tundra Exp $`` +``$Id: Deconstructing_Linux_udev_Rules.rst,v 1.107 2013/10/31 23:11:30 tundra Exp $`` You can find the latest version of this document at: