为什么 udev 更新后,新策略不起作用

为什么 udev 更新后,新策略不起作用

我已将系统中的 udev(虚拟机上的 ubuntu 服务器 14.04)更新为版本 204-5ubuntu20.18。重启系统后,NIC 无法使用可预测的名称重命名。名称为 eth*。目录 /lib/udev/rules.d/ 中没有文件 80-net-name-slot.rules。为什么新策略不起作用?还需要做什么?

# dpkg -s udev
Package: udev
Status: install ok installed
Priority: important
Section: admin
Installed-Size: 5151
Maintainer: Ubuntu Developers <[email protected]>
Architecture: amd64
Multi-Arch: foreign
Source: systemd
Version: 204-5ubuntu20.18
Replaces: systemd-services (<< 202-0ubuntu6)
Depends: libacl1 (>= 2.2.51-8), libblkid1 (>= 2.19.1), libc6 (>= 2.17), libcgmanager0, libdbus-1-3 (>= 1.0.2), libkmod2 (>= 5~), libnih-dbus1 (>= 1.0.0), libnih1 (>= 1.0.0), libselinux1 (>= 2.0.65), libudev1 (= 204-5ubuntu20.18), sysv-rc (>= 2.88dsf-24) | file-rc (>= 0.8.16), lsb-base (>= 3.0-6), util-linux (>= 2.16), procps

# udevadm info /sys/class/net/eth0
P: /devices/pci0000:00/0000:00:03.0/virtio0/net/eth0
E: DEVPATH=/devices/pci0000:00/0000:00:03.0/virtio0/net/eth0
E: ID_BUS=pci
E: ID_MODEL_FROM_DATABASE=Virtio network device
E: ID_MODEL_ID=0x1000
E: ID_NET_NAME_MAC=enx52540044f6c0
E: ID_PCI_CLASS_FROM_DATABASE=Network controller
E: ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller
E: ID_VENDOR_FROM_DATABASE=Red Hat, Inc
E: ID_VENDOR_ID=0x1af4
E: IFINDEX=2
E: INTERFACE=eth0
E: MATCHDEVID=0x0
E: MATCHIFTYPE=1
E: SUBSYSTEM=net
E: USEC_INITIALIZED=628

# udevadm test-builtin net_id /sys/class/net/eth0
calling: test-builtin
=== trie on-disk ===
tool version:          204
file size:         5662556 bytes
header size             80 bytes
strings            1265740 bytes
nodes              4396736 bytes
load module index
ID_NET_NAME_MAC=enx52540044f6c0
unload module index

# udevadm test /sys/class/net/eth0
calling: test
version 204
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

=== trie on-disk ===
tool version:          204
file size:         5662556 bytes
header size             80 bytes
strings            1265740 bytes
nodes              4396736 bytes
load module index
read rules file: /lib/udev/rules.d/40-crda.rules
read rules file: /lib/udev/rules.d/40-gnupg.rules
read rules file: /lib/udev/rules.d/40-hyperv-hotadd.rules
read rules file: /lib/udev/rules.d/42-usb-hid-pm.rules
read rules file: /lib/udev/rules.d/50-firmware.rules
read rules file: /lib/udev/rules.d/50-udev-default.rules
read rules file: /lib/udev/rules.d/55-dm.rules
read rules file: /lib/udev/rules.d/56-lvm.rules
read rules file: /lib/udev/rules.d/60-cdrom_id.rules
read rules file: /lib/udev/rules.d/60-keyboard.rules
read rules file: /lib/udev/rules.d/60-persistent-alsa.rules
read rules file: /lib/udev/rules.d/60-persistent-input.rules
read rules file: /lib/udev/rules.d/60-persistent-serial.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-dm.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-tape.rules
read rules file: /lib/udev/rules.d/60-persistent-storage.rules
read rules file: /lib/udev/rules.d/60-persistent-v4l.rules
read rules file: /lib/udev/rules.d/61-accelerometer.rules
read rules file: /lib/udev/rules.d/62-google-cloudimg.rules
read rules file: /lib/udev/rules.d/64-btrfs.rules
read rules file: /lib/udev/rules.d/70-power-switch.rules
read rules file: /lib/udev/rules.d/70-uaccess.rules
read rules file: /lib/udev/rules.d/71-biosdevname.rules
read rules file: /lib/udev/rules.d/71-seat.rules
read rules file: /lib/udev/rules.d/73-idrac.rules
read rules file: /lib/udev/rules.d/73-seat-late.rules
read rules file: /lib/udev/rules.d/75-net-description.rules
read rules file: /lib/udev/rules.d/75-persistent-net-generator.rules
read rules file: /lib/udev/rules.d/75-probe_mtd.rules
read rules file: /lib/udev/rules.d/75-tty-description.rules
read rules file: /lib/udev/rules.d/78-graphics-card.rules
read rules file: /lib/udev/rules.d/78-sound-card.rules
read rules file: /lib/udev/rules.d/80-drivers.rules
read rules file: /lib/udev/rules.d/85-hdparm.rules
read rules file: /lib/udev/rules.d/85-keyboard-configuration.rules
read rules file: /lib/udev/rules.d/85-lvm2.rules
read rules file: /lib/udev/rules.d/85-regulatory.rules
read rules file: /lib/udev/rules.d/95-udev-late.rules
rules contain 24576 bytes tokens (2048 * 12 bytes), 11594 bytes strings
1839 strings (22502 bytes), 1197 de-duplicated (11551 bytes), 643 trie nodes used
PROGRAM '/sbin/biosdevname --smbios 2.6 --nopirq --policy physical -i eth0' /lib/udev/rules.d/71-biosdevname.rules:21
starting '/sbin/biosdevname --smbios 2.6 --nopirq --policy physical -i eth0'
'/sbin/biosdevname --smbios 2.6 --nopirq --policy physical -i eth0' [7226] exit with return code 4
IMPORT builtin 'net_id' /lib/udev/rules.d/75-net-description.rules:6
IMPORT builtin 'hwdb' /lib/udev/rules.d/75-net-description.rules:12
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:03.0/virtio0/net/eth0
ID_BUS=pci
ID_MODEL_FROM_DATABASE=Virtio network device
ID_MODEL_ID=0x1000
ID_NET_NAME_MAC=enx52540044f6c0
ID_PCI_CLASS_FROM_DATABASE=Network controller
ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller
ID_VENDOR_FROM_DATABASE=Red Hat, Inc
ID_VENDOR_ID=0x1af4
IFINDEX=2
INTERFACE=eth0
MATCHDEVID=0x0
MATCHIFTYPE=1
SUBSYSTEM=net
USEC_INITIALIZED=628
unload module index


# udevadm info /sys/class/net/eth1
P: /devices/pci0000:00/0000:00:09.0/net/eth1
E: DEVPATH=/devices/pci0000:00/0000:00:09.0/net/eth1
E: ID_BUS=pci
E: ID_MODEL_FROM_DATABASE=82540EM Gigabit Ethernet Controller
E: ID_MODEL_ID=0x100e
E: ID_NET_NAME_MAC=enx525400b5f547
E: ID_NET_NAME_PATH=enp0s9
E: ID_NET_NAME_SLOT=ens9
E: ID_PCI_CLASS_FROM_DATABASE=Network controller
E: ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller
E: ID_VENDOR_FROM_DATABASE=Intel Corporation
E: ID_VENDOR_ID=0x8086
E: IFINDEX=3
E: INTERFACE=eth1
E: SUBSYSTEM=net
E: USEC_INITIALIZED=54306
E: net.ifnames=1

# udevadm test-builtin net_id /sys/class/net/eth1
calling: test-builtin
=== trie on-disk ===
tool version:          204
file size:         5662556 bytes
header size             80 bytes
strings            1265740 bytes
nodes              4396736 bytes
load module index
ID_NET_NAME_MAC=enx525400b5f547
ID_NET_NAME_PATH=enp0s9
ID_NET_NAME_SLOT=ens9
unload module index

# udevadm test /sys/class/net/eth1
calling: test
version 204
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

=== trie on-disk ===
tool version:          204
file size:         5662556 bytes
header size             80 bytes
strings            1265740 bytes
nodes              4396736 bytes
load module index
read rules file: /lib/udev/rules.d/40-crda.rules
read rules file: /lib/udev/rules.d/40-gnupg.rules
read rules file: /lib/udev/rules.d/40-hyperv-hotadd.rules
read rules file: /lib/udev/rules.d/42-usb-hid-pm.rules
read rules file: /lib/udev/rules.d/50-firmware.rules
read rules file: /lib/udev/rules.d/50-udev-default.rules
read rules file: /lib/udev/rules.d/55-dm.rules
read rules file: /lib/udev/rules.d/56-lvm.rules
read rules file: /lib/udev/rules.d/60-cdrom_id.rules
read rules file: /lib/udev/rules.d/60-keyboard.rules
read rules file: /lib/udev/rules.d/60-persistent-alsa.rules
read rules file: /lib/udev/rules.d/60-persistent-input.rules
read rules file: /lib/udev/rules.d/60-persistent-serial.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-dm.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-tape.rules
read rules file: /lib/udev/rules.d/60-persistent-storage.rules
read rules file: /lib/udev/rules.d/60-persistent-v4l.rules
read rules file: /lib/udev/rules.d/61-accelerometer.rules
read rules file: /lib/udev/rules.d/62-google-cloudimg.rules
read rules file: /lib/udev/rules.d/64-btrfs.rules
read rules file: /lib/udev/rules.d/70-power-switch.rules
read rules file: /lib/udev/rules.d/70-uaccess.rules
read rules file: /lib/udev/rules.d/71-biosdevname.rules
read rules file: /lib/udev/rules.d/71-seat.rules
read rules file: /lib/udev/rules.d/73-idrac.rules
read rules file: /lib/udev/rules.d/73-seat-late.rules
read rules file: /lib/udev/rules.d/75-net-description.rules
read rules file: /lib/udev/rules.d/75-persistent-net-generator.rules
read rules file: /lib/udev/rules.d/75-probe_mtd.rules
read rules file: /lib/udev/rules.d/75-tty-description.rules
read rules file: /lib/udev/rules.d/78-graphics-card.rules
read rules file: /lib/udev/rules.d/78-sound-card.rules
read rules file: /lib/udev/rules.d/80-drivers.rules
read rules file: /lib/udev/rules.d/85-hdparm.rules
read rules file: /lib/udev/rules.d/85-keyboard-configuration.rules
read rules file: /lib/udev/rules.d/85-lvm2.rules
read rules file: /lib/udev/rules.d/85-regulatory.rules
read rules file: /lib/udev/rules.d/95-udev-late.rules
rules contain 24576 bytes tokens (2048 * 12 bytes), 11594 bytes strings
1839 strings (22502 bytes), 1197 de-duplicated (11551 bytes), 643 trie nodes used
PROGRAM '/sbin/biosdevname --smbios 2.6 --nopirq --policy physical -i eth1' /lib/udev/rules.d/71-biosdevname.rules:21
starting '/sbin/biosdevname --smbios 2.6 --nopirq --policy physical -i eth1'
'/sbin/biosdevname --smbios 2.6 --nopirq --policy physical -i eth1' [1135] exit with return code 4
IMPORT builtin 'net_id' /lib/udev/rules.d/75-net-description.rules:6
IMPORT builtin 'hwdb' /lib/udev/rules.d/75-net-description.rules:12
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:09.0/net/eth1
ID_BUS=pci
ID_MODEL_FROM_DATABASE=82540EM Gigabit Ethernet Controller
ID_MODEL_ID=0x100e
ID_NET_NAME_MAC=enx525400b5f547
ID_NET_NAME_PATH=enp0s9
ID_NET_NAME_SLOT=ens9
ID_PCI_CLASS_FROM_DATABASE=Network controller
ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller
ID_VENDOR_FROM_DATABASE=Intel Corporation
ID_VENDOR_ID=0x8086
IFINDEX=3
INTERFACE=eth1
SUBSYSTEM=net
USEC_INITIALIZED=54306
net.ifnames=1
unload module index

答案1

2014 年,virtio 设备的“可预测”命名被删除,因为它不是实际上可以预见(IIRC,virtio 维护者特别要求将其删除)。

它于 2015 年底重新添加(使用更可靠的方法),但我怀疑 Ubuntu 是否会将该功能移植到 LTS。

相关内容