udev
and eudev
eudev
now works nicely with OpenRC and musl (apparently) and so the gentoo
developers have decided to deprecate support for eudev and save some work.
Persistent Device Naming
Keep eth0
and wlan0
but for specific devices identified by MAC address:
/etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:ca:fe:be", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:ca:fe:ba", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"
Find some attributes to use for the device, below is an example when I connect my mobile phone to use internet tethering:
# dmesg | tail -n 50
[176556.229262] usb 2-2: new high-speed USB device number 4 using xhci_hcd
[176556.229262] usb 2-2: New USB device found, idVendor=0000, idProduct=0000, bcdDevice= 0.00
[176556.229269] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[176556.229273] usb 2-2: Product: BlackBerry
[176556.229276] usb 2-2: Manufacturer: Research In Motion, Ltd.
[176556.229278] usb 2-2: SerialNumber: 4
[176556.250267] usbcore: registered new interface driver cdc_ether
[176556.296885] cdc_ncm 2-2:1.0: MAC-Address: 00:1b:21:ca:fe:b1
[176556.297061] cdc_ncm 2-2:1.0 usb0: register 'cdc_ncm' at usb-0000:00:14.0-2, CDC NCM, 00:1b:21:ca:fe:b1
[176556.355585] cdc_ncm 2-2:1.2: MAC-Address: 00:1b:21:ca:fe:b2
[176556.355871] cdc_ncm 2-2:1.2 usb1: register 'cdc_ncm' at usb-0000:00:14.0-2, CDC NCM, 00:1b:21:ca:fe:b2
[176556.355936] usbcore: registered new interface driver cdc_ncm
[176556.360560] usbcore: registered new interface driver cdc_wdm
[176556.362455] usbcore: registered new interface driver cdc_mbim
[176556.368137] cdc_ncm 2-2:1.2 enp0s20u2i2: renamed from usb1
[176556.393161] cdc_ncm 2-2:1.0 enp0s20u2: renamed from usb0
# find /sys/ | grep enp0s20u2i2
...
/sys/devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.2/net/enp0s20u2i2/flags
# udevadm info -a -p '/sys/devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.2/net/enp0s20u2i2/flags' |more
looking at device '/devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.2/net/enp0s20u2i2':
KERNEL=="enp0s20u2i2"
SUBSYSTEM=="net"
DRIVER==""
ATTR{addr_assign_type}=="0"
ATTR{addr_len}=="6"
ATTR{address}=="00:1b:21:ca:fe:b2"
...
# vi /etc/udev/rules.d/10-blackberry.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:ca:fe:b2", ATTR{type}=="1", KERNEL=="usb*", NAME="usb1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:ca:fe:b1", ATTR{type}=="1", KERNEL=="usb*", NAME="usb0"
I do not know what ATTR{type}
means but it does match the value in the
udevadm
output.
Now the BlackBerry tethering should use usb0
and usb1
as the kernel
intended and will ALWAYS use them... until there is no more
BlackBerry, oh wait...
References
- The Geek Diary
- Redhat KB Article
- StackOverflow Answer
- Specifically about USB to UART Serial interfaces: Embedded Related