I have RPI3 board with mender integrated and using readonly rootfs. For networking I’m using systemd-networkd. I have symlinked /etc.hostname to /data/etc/hostname. My issue is that after board get dhcp from server it will report in list of connected devices hostname raspberrypi and not hostname set per board. Issue is that /data partition is mounted late and in this case systemd use default hostname and hostname update doesn’t affect one in lease. Asked on support in systemd folks but response was to mount /data in initrd to be present in early systemd stages and it should work (response from systemd creator):
Two issues: /etc/hostname is read very early during boot, before PID 1 starts the first other userspace program. This means you'd have to mount that fs from the initrd already, to be applied. hostnamed and friends live in a sandbox these days, that prohibit write access outside of /etc, and read access to various other dirs. If you play such symlink games, you have to turn that off. See the systemd-hostnamed.service service file, specifically ProtectSystem= and similar options. That all said, instead of introducing /data and keeping the whole of the OS read-only, I'd recommend to instead operate with a read-only /usr only, combined with a writable / that comes up in the initrd already and is automatically populated on first boot. i.e. keep /etc and everything else as empty as possible, and store only the stuff in it actually needed. systemd itself is all set up for this mode, and is happy if there's no configuration in /etc around. Some distros are not that happy with such a set up however, they require some bits in /etc existing. Ideally distros would be fixed to not require that and be happy with /etc entirely empty, but until then you can use tmpfiles.d/'s "C" lines copy in basic necessary configuration into /etc from /usr/share/factory/. Lennart
Just want to ask if anyone doing it similar way or have some other ideas how to solve this issue. Thanks a lot.