2

i'm building an embedded prototyp with a raspberry pi 3b+ and its booting via pxe from the network read only.

Multiple devices share the same root file system and just the boot folders are customized for every pi.

I want to configure all hostnames of the pis with the help of the cmdline.txt.

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/nfs nfsroot=172.30.1.1:/nfs/disp_root_fs,vers=3 r ip=dhcp rootwait elevator=deadline kernel.hostname=disp13

But the kernel.hostname is not set in the running system. Instead the hostname is just the ip of the pi that it got from the dhcp server.

Does anybody know where the pi is setting the hostname to the ip? I would try to comment it out so the cmdline variable will be the hostname.

Thanks in advance.

Artur
  • 23
  • 2

2 Answers2

1

Use the NFS format for the ip parameter instead.

ip=::::hostnamegoeshere:eth0:dhcp

If the DHCP server agrees, it should respond with a hostname field as well and potentially update DNS (that's what dnsmasq does). That makes them look unique to the DHCP server from early boot without assigning static IPs to them by MAC.

Another thing to try is setting the MAC for eth0 manually to something you came up with.

smsc95xx.macaddr=b8:27:eb:aa:aa:aa

This would save you the trouble of configuring identities on both TFTP and DHCP server based on serial and MAC.

Black belt option

Write your own initramfs script that reads /proc/cmdline and infers configuration from those parameters. Custom parameters will be passed to that proc file even if they are ignored by the kernel.

ferrix
  • 111
  • 7
1

If the kernel option in /boot/cmdline.txt does not work you can use the DHCP server. It has an option to send the hostname within its lease for the device. This is the usual way for a centralized management of multiple hostnames. I know that the isc-dhcp-server can do it. Just add a group to your dhcpd.conf, for example:

group {
    use-host-decl-names on;

    host raspi1 {
        hardware ethernet 00:d0:e0:93:b3:68;
    }
    host raspi2 {
        hardware ethernet 00:80:3f:2a:31:1a;
    }
}

This will map a hostname to the mac address of the RasPi and it will also update the DNS server with the given name if you have configured dynamic DNS on your DHCP server.

Ingo
  • 42,961
  • 20
  • 87
  • 207