7.5 Modifying Udev Rules

The order in which rules are evaluated is important. Udev processes rules in lexical order. If you want to add your own rules, you need udev to find and evaluate these rules before the default rules.

  1. Create a rule file under /etc/udev/rules.d with a file name such as 10-local.rules that udev will read before any other rules file.

    For example, the following rule in 10-local.rules renames /dev/sdb to /dev/my_disk:

    KERNEL=="sdb", SUBSYSTEM==“block", NAME=“my_disk”

    Listing the device files in /dev shows that udev has not yet applied the rule:

    # ls /dev/sd* /dev/my_disk
    ls: cannot access /dev/my_disk: No such file or directory
    /dev/sda  /dev/sda1  /dev/sda2  /dev/sdb
  2. Restart udev, use the start_udev command:

    # start_udev
    Starting udev:                         [OK]

    After Udev processes the rules files, the name of the device file has changed to /dev/my_disk:

    # ls /dev/sdb* /dev/my_disk
    /dev/my_disk  /dev/sda  /dev/sda1  /dev/sda2

To undo the changes, remove your rules file and run start_udev again.