From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Eudev and the translation is 40% complete.
Outdated translations are marked like this.
Other languages:
不要混淆 udev.
eudev has changed maintainers from Gentoo to an independent project. eudev will now remain in Gentoo, although it's still recommended to use udev. The transition should be uneventful, however the corresponding News Item must be read and followed to avoid any issues.

eudev is Gentoo's fork of udev, systemd's device file manager for the Linux kernel.[1] It manages device nodes in /dev and handles all user space actions when adding or removing devices.

The goal of eudev is to obtain better compatibility with existing software such as the OpenRC init system, Upstart init system, older Linux kernels, various toolchains, and anything else required[2] by (but not well supported through) udev.

Similar to ebuild, eclass, emerge, etc. eudev's name follows the 'E' prefix convention started by Gentoo's founder Daniel Robbins.

System configurations running systemd have no use for eudev.


大多数Linux用户都知道 /dev/sda1 只是内核找到的第一个磁盘上的第一个分区的快速方法。这很简单,对吧?

但请考虑USB,IEEE 1394,热插拔PCI等热插拔设备。这些设备的第一个设备是什么?而且持续多久?当第一个设备消失时,其他设备会被命名为什么?这将如何影响正在进行的事务?如果一个打印作业突然从高端激光打印机转移到几乎死机的矩阵打印机,仅仅是因为有人决定拔下激光打印机上的插头(恰好是第一台打印机),这会不会很有趣?

进入设备管理器。一个现代设备管理器(包括 udeveudev)必须:

  • 在用户空间中运行。
  • 动态创建和删除device file
  • 提供一致的设备命名。
  • 提供用户空间应用程序接口(API)。

每当设备结构发生变化时,内核都会发出一个由设备管理器获取的 uevent ,然后设备管理器遵循 /etc/udev/rules.d, /run/udev/rules.d/lib/udev/rules.d 目录中声明的规则,根据uevent中包含的信息,它会找到触发和执行所需操作所需的规则。这些动作可能涉及设备文件的创建或删除,还可能触发将特定固件文件加载到内核内存中。


USE 标记

Some packages know the udev USE flag for enabling virtual/udev integration.

USE flags for sys-fs/eudev Linux dynamic and persistent device naming support (aka userspace devfs)

kmod enable module loading through libkmod
rule-generator install legacy rule generator rules and support scripts - note that the functionality within was dropped from sys-fs/udev as it is not stable in all cases; use at your own risk
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
split-usr Enable behavior to support maintaining /bin, /lib*, /sbin and /usr/sbin separately from /usr/bin and /usr/lib*
static-libs Build static versions of dynamic libraries as well
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)


To avoid registration in the world set, the oneshot option should be used.

root #emerge --ask --oneshot sys-fs/eudev



The RC name is udev, not eudev. It needs to be registered in the sysinit runlevel.

root #rc-update add udev sysinit
 * rc-update: udev already installed in runlevel `sysinit'; skipping

From sys-fs/udev-init-scripts version 29 onward, udev-trigger should also be added to the sysinit runlevel.

Optional: Keep classic network interface naming

内核提供的网络设备名称列入eth0 或 wlan0 等通常可以通过 /lib/udev/rules.d/80-net-name-slot.rules udev 规则在系统启动时更改参见 dmesg

为了保持传统命名,这个规则可以用 /etc/udev/rules.d 目录中用同样命名的空文件覆盖:

root #touch /etc/udev/rules.d/80-net-name-slot.rules

Alternatively add net.ifnames=0 to the kernel command line, change the default policy or create a custom one.

An interesting resource related to the network naming is I don't like this, how do I disable this on the Freedesktop wiki.

Migrating from udev to eudev

Migrating from udev to eudev is straightforward.

First, disable the udev USE flag for systemd-utils:

文件 /etc/portage/package.useSwitching udev to eudev in package.use
sys-apps/systemd-utils -udev
root #emerge --ask --oneshot sys-fs/eudev
root #emerge --ask --oneshot sys-fs/eudev

In case the system uses multilib and, for example, has the abi_x86_32 USE flag active against the older udev package, then don't forget to change it too:

文件 /etc/portage/package.use在 package.use 从 udev 到eudev
# sys-fs/udev abi_x86_32
sys-fs/eudev abi_x86_32

Use new predictable network interface naming

The new network interface naming convention is not the same. So the symlinks used by netifrc will need to be re-linked. Use /etc/init.d/net.lo as a link target for whatever interface names need to be added. Be sure to replace <interface_name> in the commands below with the Ethernet interface names present on the system. It is possible to discover which interfaces exist by running the ip link command:

user $ifconfig

Create symbolic links for the existing interfaces in the /etc/init.d/ and /etc/conf.d/ directories:

root #ln -s /etc/init.d/net.lo /etc/init.d/net.<interface_name>
root #ln -s /etc/conf.d/net.lo /etc/conf.d/net.<interface_name>

Add the script(s) to the default runlevel to have the interface(s) start automatically:

root #rc-update add net.<interface_name> default

Keep classic network interface naming

Using an empty file at /etc/udev/rules.d/80-net-name-slot.rules to enforce classic network interface naming will not work if migrating from eudev to udev. See Optional: Disable or override predictable network interface naming for instructions relevant to udev.


使用 udevadm

开始 udevadm monitor 并且观察发生的变化:

user $udevadm monitor

Get device info using udevadm info followed by the device path:

user $udevadm info -p /devices/pci0000:00/0000:00:1d.7

Get the device path using its name:

user $udevadm info -q path -n input/mouse1

Test an event run using udevadm test followed by the device path for which an event is to be tested:

user $udevadm test /devices/pci0000:00/0000:00:1d.7

To get a list of all udevadm commands:

user $udevadm -h

Migrating older releases

从 udev 171-r10 到 eudev 1.2-r1

在 Gentoo 论坛上查看 这个帖子

Broken system switching from udev to eudev

在 Gentoo 论坛上查看 这个帖子




  1. Bug 575718 - Request for council decision RE virtual/udev default provider, Gentoo's Bugzilla Main Page, (Last modified) February 27th, 2016. Retrieved on March 1st, 2016.
  2. Project:Eudev, Gentoo Wiki, (Last modified) November 12th, 2015. Retrieved on March 11th, 2016.