0

I'm trying to set up a bunch of Pis together on a subnet. Each Pi should have its own unique static IP address. This all well and good for 1 or 2 Pis, but I have a LOT of them.

Currently, I attach all the Micro SD cards for each Pi into many interconnected USB hubs, where I will simultaneously transfer over Raspbian to all the Pis at once.

The issue I'm running into is how do I set a different static IP on each of those Pis without having to boot each one up one by one and go and manually enter it.

One thought I had would be to use a Python script to edit the /boot partition of the SD card for each Pi - and make each Pi auto-run a script to edit their static IPs on first boot (and make themself auto-reboot following that). However, I can't seem to find a way to auto-run a script from the /boot partition. I'm also open to any other creative suggestions :).

EDIT: Ideally I want to be able to make changes to the SD card from my Mac, so it must be within the /boot partition since Macs can't read/write to ext4 file systems without paying for software to do

4

Haven't read the discussion on the chat complete (to much for scanning) but I suppose you create a master image and copy it over to your RasPis. you say:

Ideally I want to be able to make changes to the SD card from my Mac, so it must be within the /boot partition since Macs can't read/write to ext4 file systems without paying for software to do

I also suppose you setup the static ip address in dhcpcd.conf. Then on your master image you can easily move dhcpcd.conf to the boot partition and symlink to it:

rpi ~$ sudo mv /etc/dhcpcd.conf /boot/
rpi ~$ sudo ln -s /boot/dhcpcd.conf /etc/dhcpcd.conf

Now you can modify it on the /boot partition from your Mac and Raspbian will see it in /etc/dhcpcd.conf.

  • 1
    this is a fantastic suggestion. Hadn't thought of doing that at all. Very creative solution. Thank you – Matt Aug 16 '18 at 19:24
0

You can create a loop back device from the official image and mount the rootfs into your system where you can edit whatever files. use kpartx -a to get two loop back devices in /dev/mapper/ dir and then mount the second one which refers to rootfs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.