I have a large volume of devices that boot from a TFTP server and mount their filesystem as a read-only NFS share. All these devices boot from the same custom raspbian image, which saves us a lot of space as we don't have to store one image per device.
To help manage these devices we are trying to use ddns so we can find a device by its hostname. The problem is that the hostname is read from /etc/hostname and as all devices share their image they all have the same hostname.
I have tried changing this manually on boot by reading the serial from /proc/cpu_info:
- Both a service and init.d script that starts before the network is up that edits /etc/hostname manually. This did not work as the file is read-only.
- Symlinking the /etc/hostname file to a ramdisk so that is its writable. For some reason soft symlinks do not work and hard links can't be made between two different partitions.
- Editing the binary for systemd-hostnamed so that it points to a different file. This caused crash on boot.
I'm hoping that there is a way to set the hostname on a read-only system like this but if not I am open to hearing an alternative to ddns and hostnames.