for my project on rpi3 I want to use different hostname for every device. I’ve tried just symlink /etc/hostname to /data/etc/hostname but seems it’s not working easily (look this systemd reply )Anyone did something similar and would be willing to share? Thanks.
I do something similar and do it by having a oneshot systemd service that has After=config.mount set, and runs /bin/hostname -F /etc/hostname. Seems to work well!
systemd has the concept of a transient hostname that can probably be utilized here. Basically, if your rootfs is read-only, you obviously can’t write to /etc/hostname and probably don’t want to remount rw to do so. I think you can just call something like “hostnamectl --transient set-hostname foo” in a start script. I’m not sure if there are still programs out there that will directly read from /etc/hostname so it may fail in that case.