# Searching for udev/eudev rule writing a modern how-to.

## TheLexx

I'm looking for a how-to guide for writing my own udev/eudev rules. The newest version of a guide I could find was at http://www.reactivated.net/writing_udev_rules.html, which was last revised in 2008. There have been many changes to the system since then, such as the upgrade from udevinfo to udevadm and the move from /sys/block/ to /sys/class/block/.  Back when the udev system was first released, I wrote a few rules that worked with with an old system. Now I have seam to have forgotten the basic of rule writing and many of the tools have changed.

Here is a list of questions I am having difficulty with.

1. How can the auto rule making system be controlled so that it does not messing up the hand written rules?

2. While there can be many SYMLINKs for a device there can only be one NAME for a device. If multiple rules match a device which one gets to chose the NAME?

3. Can the resultant "device name" or "link name" be based on a string supplies by the udeve/eudev system?

   example  DEVPATH=/devices/pci0000:00/0000:00:11.1/ide0/0.0 -> ...c0d0

            DEVPATH=/devices/pci0000:00/0000:00:11.1/ide0/0.1 -> ...c0d1

            DEVPATH=/devices/pci0000:00/0000:00:11.1/ide1/1.1 -> ...c1d1

4. Is there a way to have one rule preempt another. Example: If a device that uses usb_storage.ko is recognized as a special device like a camera or an *pod(ipod). I want to assign it a link camera or xpod. If the device is not recognized, I want to link it to thumb0, thumb1, etc. in the order detected without an sort of persistent naming. If the device is determined to be a camera or xpod I do not want to even create a link to thumb(x).

Does anyone know if such a guide exists?

----------

## Dominique_71

1) It depend of what you mean by messing up.

2) The first rule with a NAME that match fix it. According to 'man udev', "All rules files are collectively sorted and processed in lexical order, ...".

3) In the NAME or SYMLINK key, you can put whatever name you want to use, if it is your question.

4) I think yes, but have no idea how.

----------

