pr6srm
Posts: 4
Joined: Mon Mar 05, 2012 2:36 pm

Network boot using serial number to define root directory

Mon Jan 06, 2020 11:17 pm

I’ve read the appropriate network boot manuals and help files and can see that the network client pi will seek “/#serial#/start.elf” if available. However, I’m struggling to make this work.

My setup is as follows:

||== pf.local [10.0.0.254, pfSense Router, DHCP server]
||
||
||==== picentral.local [10.0.0.37, 3B, rootfs on a 1TB USB disk, tftpd-hpa, nfs-kernel-server]
||
||
||==== rpi01.local [10.0.0.41, 3B, #serial001, root set to boot from nfs share on 10.0.0.37]
||
||==== rpi02.local [10.0.0.42, 3B, #serial002, root set to boot from nfs share on 10.0.0.37]
||
||== etc etc

On picentral, I have the following mounts from the USB drive:

/sda1/rootfs
/sda2/clientfs
/sda3/space

/rootfs is as you would expect for picentral.local
/clientfs has sub-directories for each client rootfs (/rpi01, /rpi02, etc...) and tftpboot for the boot files
/space is a network share for all on the network

What I am trying to do is understand how to arrange the folder structure in the /tftpboot folder so I can have individual cmdline.txt files that the direct the client to the correct rootfs. At the moment I have something resembling this:

10.0.0.37/clientfs/tftpboot/
||
||== bootcode.bin
||
||==.../#serialrpi01#/.
|| ||
|| ||== start.elf, cmdline.txt, config.txt, etc...
||
||==.../#serialrpi02#/.
|| ||
|| ||== start.elf, cmdline.txt, config.txt, etc...
||
etc etc...

My plan is then that the cmdline.txt “root=“ instruction in each client sub directory can be tailored to direct the client as to which rootfs to select. Network booting, per se, works fine and I can boot a network client OK with this setup. However, when I change that client over to another pi, with a different serial, it seems to boot from the same 10.0.0.37/clientfs/rpi01 directory regardless of what I put in the tftpboot sub directory cmdline.txt.

I’m sure I’m missing something pretty simple, but at the moment I need another pair of eyes to point it out me. Any thoughts would be gratefully appreciated.

incognitum
Posts: 477
Joined: Tue Oct 30, 2018 3:34 pm

Re: Network boot using serial number to define root directory

Mon Jan 06, 2020 11:46 pm

The logs of your tftp server software confirm that the client Pi actually did download cmdline.txt from "/tftpboot/#serial#/cmdline.txt" and not from anywhere else?
However, when I change that client over to another pi, with a different serial, it seems to boot from the same 10.0.0.37/clientfs/rpi01 directory
Running "cat /proc/cmdline" on the client Pi after it booted confirms that this is the case?
(make sure you look at /proc and not /boot. As proc should show the value that came from tftp instead of whatever is on nfs)

User avatar
dickon
Posts: 1436
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: Network boot using serial number to define root directory

Mon Jan 06, 2020 11:53 pm

In the thread at https://www.raspberrypi.org/forums/view ... 9&t=253314 I more or less dealt with this. Start there, and feel free to ask for details.

Return to “Advanced users”