top | item 29348355

(no title)

moreentropy | 4 years ago

While these tutorials are a great way to teach system administration to those who want to start tinkering, I wish people would put more energy into building well crafted firmware images using frameworks like openembedded or buildroot and teaching people how to use those.

Most of the raspbian-based tutorials or images out there treating the raspberry pi like a normal server are just going to trash the SD or fail because system state is mutating in unexpected ways.

Start building immutable images that hold temporary data strictly in RAM.

discuss

order

saghul|4 years ago

That sounds actually like a good idea. Do you have a resource on how to get started?

ghoul2|4 years ago

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.

moreentropy|4 years ago

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:

https://buildroot.org/downloads/manual/manual.html#outside-b...

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:

https://github.com/markuslindenberg/dvbheadend

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.

https://github.com/markuslindenberg/habfw

Shish2k|4 years ago

Speaking of building immutable images - I want to do that for one of my projects, but scanning the docs for buildroot and yocto, I don’t see anything about applying updates - which is the part where I most want an off-the-shelf battle-tested solution so I won’t need to fly out and fix it in person.

Specifically, I want to have a disk image with two root partitions - by default (ie, what I flash to the SD card) the first partition has a read-only root FS and the second is empty. When an upgrade is ready, the system downloads the update from the internet, writes it to the second partition, and reboots - if the reboot is successful and the system passes health checks, it marks partition 2 as the default. If something goes wrong, it reboots again back into the original partition. (Then when v3 comes out, v2 downloads and writes it to the first partition, etc)

I keep thinking “surely this must be a solved problem?”, but I can find very little information about it; and the few things I can find are proprietary cloud-based management systems, when I’d much rather have my image hard-coded to poll an update-feed-URL that I control myself...