3

I’m using systemd-nspawn and qemu-arm-static to boot into a Raspberry Pi OS image to apply customizations to the stock image before flashing it onto an SD card.

  • The host machine is Ubuntu 20.10 (systemd version: 246.6-1ubuntu1)
  • The guest OS is Raspberry Pi OS (Aug. 2020, based on Debian Buster, systemd version: 241)

This is working great: I can install packages using apt-get, enable services using systemctl, etc.

But there is one exception: hostnamectl, which is the preferred way to set the hostname on modern Linux distributions.

# hostnamectl
Failed to query system properties: Connection timed out

I’m seeing the following output in the system log:

Oct 26 20:08:05 raspberrypi dbus-daemon[219]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service' requested by ':1.23' (uid=0 pid=2300 comm="/usr/bin/qemu-arm-static /usr/bin/hostnamectl " label="unconfined")
Oct 26 20:08:05 raspberrypi systemd[1]: Starting Hostname Service...
Oct 26 20:08:05 raspberrypi systemd[2303]: systemd-hostnamed.service: Failed to set up network namespacing: Input/output error
Oct 26 20:08:05 raspberrypi systemd[2303]: systemd-hostnamed.service: Failed at step NETWORK spawning /lib/systemd/systemd-hostnamed: Input/output error
Oct 26 20:08:05 raspberrypi systemd[1]: systemd-hostnamed.service: Main process exited, code=exited, status=225/NETWORK
Oct 26 20:08:05 raspberrypi systemd[1]: systemd-hostnamed.service: Failed with result 'exit-code'.
Oct 26 20:08:05 raspberrypi systemd[1]: Failed to start Hostname Service.
Oct 26 20:08:30 raspberrypi dbus-daemon[219]: [system] Failed to activate service 'org.freedesktop.hostname1': timed out (service_start_timeout=25000ms)

I’m using the following command to boot into the image:

systemd-nspawn -b -i /dev/loop3p2

As a workaround for setting the hostname, I’m using the classic method:

# echo my-pi > /etc/hostname
# echo "127.0.1.1 my-pi" >> /etc/hosts

This is working perfectly fine, but I’d still like to learn why the hostnamectl approach doesn’t work when running within systemd-nspawn, and whether this is the expected behavior.

aaronk6
  • 141
  • 1
  • 7
  • It's caused by user emulation from qemu. If I run the *same* debian armhf LXC container once from x86, systemd-hostnamed fails, once from a real armhf cpu (over nfs), it works. Same for a few network commands like iptables or nft(ables) which get netlink sockets not working correctly. – A.B Oct 26 '20 at 22:03
  • 2
    I have the same issue with Ubuntu Server 18.04 when I'm trying to change the hostname with ansible... – Gergely Lukacsy May 27 '21 at 13:43

0 Answers0