I have just rebuilt a container so it has all the latest stuff. I did it to take on board the sbin shift. Now its network doesn't work.
When trying to start a simple static configuration, netctl (actually, systemd) borks becuase a dependency on "sys-subsystem-net-devices-eth0.device" isn't met.
Jun 07 10:09:48 xxxx systemd: Expecting device sys-subsystem-net-devices- -- Subject: Unit sys-subsystem-net-devices-eth0.device has begun with start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit sys-subsystem-net-devices-eth0.device has begun starting up. Jun 07 10:11:18 xxxx systemd: Job sys-subsystem-net-devices-eth0.device/s Jun 07 10:11:18 xxxx systemd: Timed out waiting for device sys-subsystem- -- Subject: Unit sys-subsystem-net-devices-eth0.device has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/be02c -- -- Unit sys-subsystem-net-devices-eth0.device has failed. -- -- The result is timeout. Jun 07 10:11:18 xxxx systemd: Dependency failed for Network (Static Host) -- Subject: Unit firstname.lastname@example.org has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/be02c -- -- Unit email@example.com has failed. -- -- The result is dependency.
I think this happens because the dependency is a udev device and udev does not run inside lxc and, therefore, the device doesn't exist.
I can prove the network stack is ok by manually starting the network
ip addr add 10.0.1.2/8 dev eth0 ip route add default via 10.0.0.138 echo "nameserver 10.0.0.138" > /etc/resolv.conf
This all worked fine with netcfg. I am not sure what to do now - any advice appreciated ...
You can edit the service file and remove the udev dependencies here:
This might fail if the hardware is not ready yet. I guess that is not a problem in LXC, because the LXC host has already set up the hardware?
Thanks @teateawhy for pointing that out. I was thinking along the same lines and I now have it working. Just editing the unit file is, however, not enough because netctl writes (and can overwrite) this file. I patched netctl to detect lxc and to not add the dependencies to the unit if running in LXC. This works.
A secondary problem is that the interface is already up when LXC starts and netctl refuses to start a profile that uses an interface that is already up. This one was solved by adding an entry "ForceConnect=yes" to the netctl profile. This option wasn't documented on the man page for netctl.profile but I quickly discovered it by looking at the code for "/usr/lib/network/network" - this is what the systemd unit calls to start/stop the netctl profile.
I have raised a bug report for this and supplied my patch.