Operations 9 min read

Understanding and Applying udev Rules for Linux Device Management

This article explains the evolution of Linux device management, introduces udev’s architecture and key features, details rule file syntax and operators, and provides practical examples—including disabling VXLAN offload, setting I/O scheduler, and enabling SR‑IOV—complete with command‑line snippets.

NetEase Game Operations Platform
NetEase Game Operations Platform
NetEase Game Operations Platform
Understanding and Applying udev Rules for Linux Device Management

Chen Wenqin, a senior operations engineer at NetEase Games, shares his extensive experience in managing the company’s private cloud platform and offers insights into using udev for device management.

Before Linux 2.6, the devfs virtual file system handled devices under /dev , but it suffered from nondeterministic naming; after 2.6, sysfs introduced a device‑tree model and udev was built on top of it to provide flexible, user‑space device handling.

Key points of udev:

udev runs as the udevd daemon and relies on sysfs.

Custom device files can be created by defining udev rules, giving it great flexibility.

The udevadm command-line tool sends instructions to udevd .

Typical capabilities include renaming devices, creating symlinks, assigning names based on script output, changing permissions/ownership, and triggering scripts on device add/remove events.

udev configuration files reside in /etc/udev/udev.conf (global settings) and /etc/udev/rules.d/ (individual rules ending with .rules ). Each non‑empty line is a rule composed of comma‑separated key‑value pairs; == denotes matching keys, while = assigns values. For example, the default 70-persistent-net.rules assigns stable names to network interfaces based on MAC addresses.

Operators and common keys/variables are illustrated with several diagrams in the original article; they cover matching operators, assignment keys, internal variables, wildcards, and more.

Practical udev rule examples:

Case 1 – Disable VXLAN offload on Broadcom 10 GbE cards to avoid driver crashes: SUBSYSTEM=="net", ACTION=="add", DRIVERS=="bnx2x", RUN="/sbin/ethtool -K %k tx-udp_tnl-segmentation off"

Case 2 – Set I/O scheduler to deadline for all disks: ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/scheduler}="deadline"

Case 3 – Enable maximum SR‑IOV virtual functions on PCI devices: SUBSYSTEM=="pci", ATTR{sriov_totalvfs}!="0", ATTR{sriov_numvfs}="$attr{sriov_totalvfs}"

Using udevadm :

Query a device’s subsystem: udevadm info /dev/sda | grep SUBSYSTEM

Recursively list all attributes of a device: udevadm info /sys/class/net/eth0 -a

Test a rule (note that RUN keys are not executed in test mode): udevadm test /sys/class/net/eth0

Trigger rules manually: udevadm trigger -c add -s net

References for further reading include the official udev rule documentation and tutorials on writing udev rules.

automationOperationsLinuxdevice managementsysfsudev
NetEase Game Operations Platform
Written by

NetEase Game Operations Platform

The NetEase Game Automated Operations Platform delivers stable services for thousands of NetEase titles, focusing on efficient ops workflows, intelligent monitoring, and virtualization.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.