Eudev

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Eudev and the translation is 51% complete.
Outdated translations are marked like this.
Other languages:
Resources
不要混淆 udev.

eudev is a 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.

/dev目录

大多数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.

Cannot load package information. Is the atom sys-fs/eudev correct?

Emerge

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

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

配置

RC服务

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

警告
This section is obsolete. See Udev#Optional: Disable_or_override_predictable_network_interface_naming for updated instructions.

内核提供的网络设备名称列入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.

故障排除

使用 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
/devices/pci0000:00/0000:00:1d.7/usb1/1-3/1-3.4/1-3.4:1.0/0003:046D:C404.0006/input/input24/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.