2.2. udev device naming rules


Userspace device manager (udev) subsystem allows you to define rules for assigning persistent names to devices. These rules are stored in a file with a .rules extension.

There are two primary locations for storing the udev rules:

  • /usr/lib/udev/rules.d/ directory contains default rules that come with an installed package.
  • /etc/udev/rules.d directory is intended for custom udev rules.
注意

If a rule from /usr/lib/udev/rules.d/ is modified, it will be overwritten by the rules file of the package during an update. Hence, any manual or custom rule should be added in /etc/udev/rules.d where it is retained until removed explicitly. Before use, udev rules from both directories are merged. If a rule in /etc/udev/rules.d has the same name as one in /usr/lib/udev/rules.d/ the one in the former takes precedence.

The purpose of these rules is to ensure that storage devices are consistently and predictably identified, even across system reboots and configuration changes.

udev rules define actions to execute based on incoming events that notify about adding, changing or removing a device. This also helps to collect values for the persistent storage attributes and direct udev to create the /dev content based on the collected information. The udev rules are written in human-readable format using key-value pairs.

In the case of storage devices, udev rules control creation of symbolic links in the /dev/disk/ directory. These symbolic links provide user-friendly aliases for storage devices, making it more convenient to refer to and manage these devices.

You can create custom udev rules to specify how devices should be named based on various attributes such as serial numbers, World Wide Name (WWN) identifiers, or other device-specific characteristics. By defining specific naming rules, you have precise control over how devices are identified within the system. To create a specific custom symbolic link in /dev for a device see the udev(7) man page on your system.

While udev rules are very flexible, it is important to be aware of udev limitations:

  • Accessibility Timing: Some storage devices might not be accessible at the time of a udev query.
  • Event-Based Processing: The kernel can send udev events at any time, potentially triggering rule processing and link removal if a device is inaccessible.
  • Processing Delay: There might be a delay between event generation and processing, especially with numerous devices, causing a lag between kernel detection and link availability.
  • Device Accessibility: External programs invoked by udev rules, like blkid, might briefly open the device, making it temporarily inaccessible for other tasks.
  • Link Updates: Device names managed by udev in /dev/disk/ can change between major releases, requiring link updates.

The following table lists the symlinks available in /dev/disk.

Expand
Device typeNonpersistent Name (Kernel Name)Persistent Symlink Names

Real Devices

nvme (Non-Volatile Memory Express)

/dev/nvme*

/dev/disk/by-id/nvme-<wwid> /dev/disk/by-id/nvme-<model>_<serial>_<nsid>

scsi (Small Computer System Interface)

/dev/sd*, /dev/sr*

/dev/disk/by-id/scsi-<model>_<serial> /dev/disk/by-id/wwn-<wwn> /dev/disk/by-id/usb-<vendor>_<model>_<serial>-<instance> /dev/disk/by-id/ieee1394-<ieee1394_id> /dev/disk/by-path/ip-<ip_address>:<ip_port>-iscsi-<iqn_name>-lun-<lun_number> /dev/disk/by-id/scsi-0<vendor>_<model>_<id> /dev/disk/by-id/scsi-1<t10_vendor_id> /dev/disk/by-id/scsi-2<eui64_id> /dev/disk/by-id/scsi-3<naa_regext_id> /dev/disk/by-id/scsi-3<naa_reg_id> /dev/disk/by-id/scsi-3<naa_ext_id> /dev/disk/by-id/scsi-3<naa_local_id> /dev/disk/by-id/scsi-8<name> /dev/disk/by-id/scsi-S<vendor>_<model>_<serial>

ata (Advanced Technology Attachment)/atapi (ATA Packet Interface)

/dev/sd*, /dev/sr*

/dev/disk/by-id/ata-<model>_<serial> /dev/disk/by-id/wwn-<wwn>

cciss (Compaq Command Interface for SCSI-3 Support)

/dev/cciss*

/dev/disk/by-id/cciss-<model>_<serial> /dev/cciss/<ccissid>

virtio (Virtual Input Output)

/dev/vd*

/dev/disk/by-id/virtio-<serial>

pmem (Persistent Memory)

/dev/pmem*

/dev/disk/by-id/pmem-<uuid>

mmc (MultiMedia Card)

/dev/mmcblk*

/dev/disk/by-id/mmc-<name>_<serial>

memstick (Memory Stick)

/dev/msblk*

/dev/disk/by-id/memstick-<name>_<serial>

Virtual devices

loop

/dev/loop*

/dev/disk/by-loop-inode/<id_loop_backing_device>-<id_loop_backing_inode> /dev/disk/by-loop-ref/<id_loop_backing_filename>

dm (device-mapper)

/dev/dm-*

/dev/mapper/<name> /dev/disk/by-id/dm-name-<name> /dev/disk/by-id/dm-uuid-<uuid> /dev/disk/by-id/wwn-<wwn>

md (multiple device)

/dev/md*

/dev/md/<devname> /dev/disk/by-id/md-name-<name> /dev/disk/by-id/md-uuid-<uuid>

Partitions (either on top of a real or a virtual device)

(any)

(any)

/dev/disk/by-partuuid/<uuid> /dev/disk/by-partlabel/<label> /dev/…​/<persistent_symlink_name>-part<number>

LVM PVs (Logical Volume Manager Physical Volumes; either on top of a real or a virtual device)

(any)

(any)

/dev/disk/by-id/lvm-pv-uuid-<pvuuid>

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部