Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Last revisionBoth sides next revision
fuss:udev [2017/07/05 19:07] officefuss:udev [2019/03/08 22:40] – [Reloading Udev Rules] office
Line 1: Line 1:
 +====== Creating Specific Rules for Devices ======
 +
 +Usually, rules are placed in files under the ''/etc/udev/rules.d'' directory where each rule performs some action depending on some user-specified criteria that matches a connected devices. For instance, a modem may be connected to a computer and the kernel will assign via udev a device node under ''/dev/'' - however, in most cases, the actual name is chosen by the kernel (conventionally incrementally, depending on the number of already connected devices). Unfortunately, one cannot know beforehand if, following the example, a modem device will be assigned to ''/dev/ttyACM0'' or ''/dev/ttyACM1'', etc...
 +
 +To make sure that a device gets the same node under devfs via udev, rules can be added under ''/etc/udev/rules.d'' and those rules can match hardware criteria such as vendor ID, revision, etc... The first step is to issue the command:
 +<code bash>
 +udevadm info -q all -n /dev/ttyACM0 --attribute-walk
 +</code>
 +
 +where:
 +  * ''/dev/ttyACM0'' is the connected device you want to query for hardware details.
 +
 +The command will output attributes, such as ''ATTRS{idProduct}'', ''ATTRS{idVendor}'', etc... Information that can then be used to construct an udev rule.
 +
 +For instance, to match and USB device with an ''idProduct'' attribute of ''0723'' and an ''idVendor'' of ''05e3'', one could create a file at ''/etc/udev.d/rules/80-mydevice.rules'' containing:
 +<code>
 +SUBSYSTEM=="usb",ATTRS{idProduct}=="0723",ATTRS{idVendor}=="05e3",SYMLINK+="mydevice",RUN+="echo boo >/dev/null"
 +</code>
 +which will:
 +  * match a device connected through the USB subsystem,
 +  * that has an ''idProduct'' of ''0723'',
 +  * and an ''idVendor'' of ''05e3'',
 +  * as well as creating a convenient symlink in ''/dev/'' as ''/dev/mydevice'',
 +  * and additionally execute the command ''echo boo >/dev/null''
 +
 +
 +====== Reloading Udev Rules ======
 +
 +Remember that issuing:
 +<code bash>
 +udevadm control --reload-rules
 +</code>
 +
 +is insufficient and that you have to issue:
 +<code bash>
 +systemctl restart udev.service
 +</code>
 +
 +to make the rules effective.
 +
 +====== Trigger Action for Particular Set of Rules ======
 +
 +To trigger the ''net'' subsystem rules that bind to the ''add'' action, issue:
 +<code bash>
 +udevadm trigger --attr-match=subsystem=net --action="add"
 +</code>
 +
  

fuss/udev.txt · Last modified: 2022/04/19 08:28 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.