So you’ve got a firmware load built, you configured one raspberry pi to be the master, and you’ve got a bunch of other raspberry pi’s that you want to be slaves. You would like to use mDNS hostname resolution for your end devices as that is a lot simpler than manually discovering each of their ip addresses every time.

You flash your firmware to 30 different raspberry pi zeros. they’d be ready to go if only they had different hostnames. So what do you do? You can plug each of them in one by one and log in to configure them manually, but that’s horrendously mind numbing. Your firmware load needs to have some configuration parameters that you can set right on the SD card without ever having to boot up a pi

The solution is to create a file called hostname in the /boot directory of the SD card. The contents of this file will be the hostname of the pi. You can then create a script that runs on boot that will read this file and set the hostname of the pi to the contents of the file. This way you can configure all of your pi’s at once by just changing the contents of the hostname file on the SD card.

So how can we accomplish this? with this script

If you run this script at startup, it will look for a file called hostname.txt in the /boot/ partition of the SD card. If it finds it, it will use the contents of that file to set the hostname of the pi.

There are many ways to run a script on boot, I won’t go over them all here, but for this project I used the @reboot crontab entry.

The key thing is to ensure that this startup script is present in your firmware load. This is typically done by building the load on a raspberry pi and then cloning the pi and then shrinking the disk image to make sure you don’t have to deal with a 32GB file containing only 3GB of data.

Hope this helps someone out

```