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.

  • Where is that parameter documented? I cannot find any reference to it as a kernel cmd line parameter. – Dirk Oct 10 '18 at 13:30
  • sysctl --all shows all kernel parameters, i just added the one needed. – Artur Oct 10 '18 at 13:38
  • I'm no expert, but AFAIK that does not mean you can use it on the kernel cmdline. It's not mentioned in kernel.org/doc/Documentation/admin-guide/kernel-parameters.txt – Dirk Oct 10 '18 at 14:32
  • Different "dynamic" hostnames are usually given by the DHCP server. – Ingo Oct 12 '18 at 12:34
  • You are right, the cmdline options are not working, but i could manage the hostnames via the isc-dhcp daemon. Thank you – Artur Oct 13 '18 at 13:31
0

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.

0

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.

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.