Its true that buildroot/yocto-based immutable images are a lot more resilient and prevent regular sd-card death, for most one-off uses you can get 90% of the way by simply using the "overlay file system" option in raspi-config already built-into the Raspberrypi OS.
Essentially, you start with your Rpi OS, configure it the way you want it - install services etc, and once you are done, just do "sudo raspi-config", select "Performance Options" and under that enable "overlay file system" (also select "read-only /boot" when asked). Reboot when prompted to complete this setup.
This will cause all changes to go to a temporary ramfs - and these changes will be lost on reboot. Most importantly, this means your SDcard won't be written to at all during normal operation. Do note that if you are using one of the older Rpis with 1GB RAM, you might face issues with RAM availability - depending on the amount of changes you make while the overlay is enabled. RPI4 variants with 4GB/8GB ram work really well, though.
If you do need to make persistent changes, just repeat the process starting with "sudo raspi-config", disable the overlay and read-only /boot, reboot, make changes, then renable the overlay. Its is a good idea to do an apt update/upgrade every month of so after disabling overlay.
Another thing you can do is to simply use USB sticks or USB drives as boot media (on RPI4). Those have much better lifetimes than sdcards, and are much faster as well.
While this does not compare to the performance/speed/safety/etc of a fully custom buildroot/yocto image, its a good compromise considering its almost effortless.
Shameless plug: I build such custom OS images for RPI and other SBCs for a living.
>Another thing you can do is to simply use USB sticks or USB drives as boot media (on RPI4). Those have much better lifetimes than sdcards, and are much faster as well.
>Shameless plug: I build such custom OS images for RPI and other SBCs for a living.
I havent seen anyone using a rpi to usb boot other pi's via a usb hub, do you think thats possible? :-)
That needs the "boot host" rpi to be a usb device or usb otg - afaik, only the pi0 and pi4 have usb otg. These can emulate a usb storage device via the usb gadget subsystem. Additionally, only RPI4 has USB boot capability, and it does not work with all usb devices.
More importantly - something like this can only be hooked up to _one_ boot device, so the usb hub and multiple pi's are a no go. I don't see any advantage compared to just using a usb stick instead of making a rp0/rpi4 pretend to be a usb stick.
You should look into network booting the multiple pi's - if thats suitable for your use case. You will still need an sdcard in each pi to provide the network bootloader, but once the boot is done, the sdcard isn
't used anymore (until the next boot)
I have some buildroot external trees on github that build images using github actions. It's for personal stuff I needed and only need to update occasionally.
The Buildroot manual is fantastic and it's worth working through the getting started section to get an idea. It boils down to creating a br_external tree that contains everything necessary to create a custom sdcard image as documented here:
Building images from a br_external tree is pretty trivial, see the gitub actions in these example repos:
This builds a raspi4 64 bit image for tvheadend (I'm using this image for a SAT-IP TV dish w/ Kodi clients in my sister's house - so far no complaints about a crashed tv server after 1.5 years of uptime). This image runs the whole rootfs from initramfs w/o mounting a persistent root filesystem. I don't care for the additional ~150MB RAM that is used in this use case:
My most recent buildroot based raspi image builds a 32 bit image pulling binary distribution of openhab and it's recommended jre into the image, running them from a read only root filesystem. I'm using this to reliably run openhab home automation in multiple places. This repo also is a br_external tree and embarrasingly doesn't have a README yet, I really really need to write one becaus I think it's quite useful and mature.
Essentially, you start with your Rpi OS, configure it the way you want it - install services etc, and once you are done, just do "sudo raspi-config", select "Performance Options" and under that enable "overlay file system" (also select "read-only /boot" when asked). Reboot when prompted to complete this setup.
This will cause all changes to go to a temporary ramfs - and these changes will be lost on reboot. Most importantly, this means your SDcard won't be written to at all during normal operation. Do note that if you are using one of the older Rpis with 1GB RAM, you might face issues with RAM availability - depending on the amount of changes you make while the overlay is enabled. RPI4 variants with 4GB/8GB ram work really well, though.
If you do need to make persistent changes, just repeat the process starting with "sudo raspi-config", disable the overlay and read-only /boot, reboot, make changes, then renable the overlay. Its is a good idea to do an apt update/upgrade every month of so after disabling overlay.
Another thing you can do is to simply use USB sticks or USB drives as boot media (on RPI4). Those have much better lifetimes than sdcards, and are much faster as well.
While this does not compare to the performance/speed/safety/etc of a fully custom buildroot/yocto image, its a good compromise considering its almost effortless.
Shameless plug: I build such custom OS images for RPI and other SBCs for a living.