I've been trying to write a unit template to configure the network (systemd version: 187):
Now, if I uncomment any of the lines that make a reference to the device alias, then the alias itself disappears!
When I say that the alias disappears, I mean that it is no longer an alias of the real device, instead it looks like systemd believes it is a proper unit in its own, and I can see it in the output of `systemctl --all`: loaded inactive dead, without meaningful description.
If the BindTo is uncommented, that means that this unit cannot start: it tries to start the sys-subsystem-net-devices-eth0.device unit, and it times out.
If only the After is uncommented, then this unit is started anyway.
However, if I write the BindTo/After using the full name of the device (BindTo=sys-devices-pci0000:00-0000:00:03.0-net-eth0.device) then it works as expected). But that's not so useful, because I'm writing a template so I really need to use the alias.
Is my unit expected to work or am I totally misunderstanding aliases?
Yeah, this is definitely a bug -- it breaks ordering for DHCP clients and wpa_supplicant. The only workaround I know of at the moment is to explicitly load the module in /etc/modules-load.d to give the interface a better chance of existing when your unit runs.
I reported this a while ago, as well:
It's still valid in 189.
This bug also affects me. In my case, it's a USB-to-Ethernet adaptor that gets different USB addresses assigned by the kernel (usb7-7\x2d3-7\x2d3:1.0 or usb3-3\x2d3-3\x2d3:1.0). Since I can't use the device alias, as a work-around, I have to rewrite my service file upon every second reboot.
Fixing this bug would be greatly appreciated.
I've posted a patch on the systemd-devel list that should fix this problem:
Thanks Eelco, I pulled your patch for inclusion in the next release.
on Jan 24, 2017 at 21:24:31.
(provided by the Example extension).