petiepooo
Posts: 12
Joined: Wed Feb 20, 2013 8:50 pm

Simulate PXE with SD boot and kexec of new kernel?

Thu Feb 14, 2019 2:32 pm

Would it be possible to boot a Rapsberry Pi (any model) off of an SD card far enough to access WiFi, find a PXE server, query it, download the kernel/initrd, and kexec into that new kernel? If so, could enough stuff be put into that initrd to be able to boot just to the point where WiFi is available again so you could pivot to an NFS-mounted root filesystem without any need to access to the SD card again?

I'm thinking such a build could allow any Raspberry Pi model to be network-booted, via WiFi even, assuming a supported WiFi card or built-in WiFi like the Zero W. Even though it's not technically PXE, the end result would be much the same. The SD card could be small, cheap, and entirely read-only to boot (pardon the pun) once configured, making it impervious to corruption due to power interruptions.

I haven't seen this discussed anywhere, but I would think it's possible. The sticking points as I see them are how you'd present the initrd image to the new kernel, and how you'd get a WPA supplicant running within initrd for NFS access to rootfs via a WPA2 AP. Limiting it to wired Ethernet would simplify things, but put the method out of reach of Zeros or A models..

Thoughts? Suggestions?

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

Re: Simulate PXE with SD boot and kexec of new kernel?

Thu Feb 14, 2019 3:49 pm

- kexec is known broken.
- accessing the entire root file system over wifi will be slow, and sluggish.

There do are some other forms you could try.
E.g. putting a read-only file system on SD card, and only accessing home folder over wifi.

You may be able to do that relatively easy with piserver.
Which normally accesses a read-only root file system over NFS, and home directory over SSHFS
Although in your case you would put root file system and /etc/wpa_supplicant.conf on SD card.

petiepooo
Posts: 12
Joined: Wed Feb 20, 2013 8:50 pm

Re: Simulate PXE with SD boot and kexec of new kernel?

Thu Feb 14, 2019 7:12 pm

incognitum wrote:
Thu Feb 14, 2019 3:49 pm
- kexec is known broken.
- accessing the entire root file system over wifi will be slow, and sluggish.
Thanks for the tip. I should have searched more on kexec, apparently. By saying it's broken, I assume you're referring to https://github.com/raspberrypi/linux/issues/27 and such. It looks like that issue was closed as won't-fix mostly because it had been open so long that it was no longer applicable to the current kernels. However, I saw other places that, although not officially supported on ARM, it was working for some.

As for speed, I understand it would be slow. The Zero W is slow to begin with, so the hardware wouldn't be good for anything bandwidth or CPU intensive. I could envision such a setup being used for ultra-low-cost, headless IoT sensors where all that's needed is a power adapter, small SD card for the simulated-PXE environment, and the Zero W itself. Once booted, it would sleep most of the time with only an occasional MQTT publish packet with sensor readings.
incognitum wrote:
Thu Feb 14, 2019 3:49 pm
There do are some other forms you could try.
E.g. putting a read-only file system on SD card, and only accessing home folder over wifi.
I am looking for a solution that doesn't involve updating a bunch of cards every time I update the OS or make a configuration change. These devices may end up in some fairly inaccessible places. Plus, I think it's a challenging problem in search of a clever solution...
incognitum wrote:
Thu Feb 14, 2019 3:49 pm
You may be able to do that relatively easy with piserver.
PiServer appears to actually use PXE, so is limited to 3 model Bs, precisely what I'm trying to work around.

It looks like there is a way to do the wpa_supplicant in debian's initramfs: http://www.marcfargas.com/posts/enable- ... initramfs/ so that's a solved problem. As long as there's at least one kernel version available where kexec works, I'm still thinking it would be possible, even if it is slow as molasses.

Return to “Advanced users”