Use this when device names, symlinks or permissions under /dev need to be stable or custom.
udev
udev is the Linux device manager that creates /dev entries and stable symlinks like /dev/disk/by-id and by-uuid when devices appear. Custom rules in /etc/udev/rules.d set names, permissions or actions.
1. udev creates /dev nodes and symlinks (by-id, by-uuid, by-path).
2. Custom rules for stable names/permissions.
3. Test with udevadm test.
4. Reload: udevadm control --reload && udevadm trigger.
5. Events show hotplug.
kernel event → udev rules → /dev node + symlinks
Context & applicabilityCommon mistakes · platform/version boundaries
- Rules matching too broadly (all disks instead of one serial).
- Rules in
/lib/udev/rules.doverwritten by package updates — use/etc/udev/rules.d. - Long-running commands in
RUN+=(killed by udev; use a systemd unit). - Forgetting to test with
udevadm test /sys/block/sdb.
Operational reference
Fast context before you go deeper.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- udev creates /dev entries and by-id/by-uuid links.
- Custom rules go in /etc/udev/rules.d.
- Reload and trigger after rule changes.
udevadm info --query=all --name=/dev/sdX— device propertiesudevadm monitor --udev— live eventsls /etc/udev/rules.d/— custom rules
ReferenceHow it works1 section · depth on demand
Using udev
udevadm info --query=all --name=/dev/sdb
udevadm monitor --udev --property
ls -l /dev/disk/by-id/ /dev/disk/by-path/ /dev/disk/by-uuid/
Custom rule example (/etc/udev/rules.d/99-data.rules):
ENV{ID_SERIAL}=="WDC_WD40EFRX_WD-WCC4E1234567", SYMLINK+="backupdisk"
Documented example, not captured output. Reload with udevadm control --reload && udevadm trigger.
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
udev creates device nodes and stable symlinks in /dev when the kernel reports a device, using rules in /usr/lib/udev/rules.d (vendor) and /etc/udev/rules.d (local).
udevadm info --query=all --name=/dev/sdb | grep -E 'ID_SERIAL|ID_WWN|ID_PATH'
udevadm monitor --udev --property # watch events while plugging/rescanning
udevadm trigger --subsystem-match=block; udevadm settle
Example rule that sets a scheduler and a stable name for a device by serial:
# /etc/udev/rules.d/60-data.rules
ACTION=="add|change", KERNEL=="sd?", ENV{ID_SERIAL}=="SAMSUNG_MZ7L3_S6CXXX", ATTR{queue/scheduler}="none", SYMLINK+="data0"
ReferenceConfiguration & state1 section · depth on demand
Example rule
# /etc/udev/rules.d/99-backup-disk.rules
SUBSYSTEM=="block", ENV{ID_SERIAL}=="WDC_WD40EFRX_WD-WCC4E1234567", SYMLINK+="backupdisk"
Documented example, not captured output. Find attributes with udevadm info --query=all --name=/dev/sdb, reload with udevadm control --reload && udevadm trigger.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Linux Storage → udev. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.kernel.org/block/index.html · confidence 94%