Adafruit's Read-Only Raspberry Pi
raspberrypi.org
raspberrypi.org
We also handle system updates by using a A/B partitioning scheme, so you can even turn off a device in the middle of an update without breaking it. The additional benefit from that is that all system updates are atomic and self-contained, so you always have the newest version without any potential leftovers from the previous version (or the previous version if the update got interrupted). Customers that have installed our first version 3 years ago now run the exact same OS that we released today. It makes it really easy to provide support.
For obvious reasons we also need a read/write partition to store downloaded assets. We treat this partition as volatile and have an easy way to automatically verify and repair content if anything gets corrupted for whatever reason.
If you want anything running reliably on a Pi, I feel this is the only way to do this.
In addition to the system part being read-only, we also try to minimized writes to the data partition. We're using some of the ext4 settings to make sure writes happen less frequently as we're perfectly capable of recovering from lost data after a reboot.
OS: SquashFS file system (ro) -> Config partition (ro/rw) -> tmpfs partition (rw)
Player software: SquashFS file system (ro) -> Data partition (ro/rw) -> tmpfs partition (rw)
The config partition is mounted read-only, all changes are written to the tmpfs partition. We then use a script to bulk write desired files to the Config partition (i.e. remount rw, copy files, remount ro). This limits the write time to a fraction of a second (these are only small text files).
As for the data partition, we remount the partition rw when we're updating the music files and check for filesystem consistency on bootup.
We hadn't had a single system fail because of the SD card in over 2 years.
Right now there isn't a way to do remote system configuration changes (through a UI, it's doable from a command line). Most changes happen through the "apps" deployed on those devices and those configuration is treated as volatile and might get lost during power outages (but then repaired later). If we decide to allow modification of the few system settings we have, I might treat them as a new A/B cycle and recreate the complete system with the changed settings on the other partition. That way I also get automated fallback if anything is misconfigured and (for example) the device fails to connect to the new WiFi.
Otherwise this is really good to know. I guess I don't run RPi's enough because my lazy unplugs haven't been an issue...yet.
So would the solution be for the host, or some SD adapter, to provide a super-cap to ensure smooth shutdown of the SD unit as a whole?
(RPi GPIO) <-----------(resistor to 3v3)-|
(RPi microUSB in) <-------------(diode <-)------+---- Vcc
| Supercap
(RPi GND) ----------------------------------- GND
When the supercap is huge enough (or, for what its worth, use a powerbank with passthrough capability!), this should work - when the GPIO goes low, the system can initiate a safe shutdown, and especially it can signal a "shutdown" signal to the microSD.I certainly wouldn't want to just unplug them from power.
Rather than superstitious behavior, we need cheap test jigs that can (for example) validate newly-purchased SD cards so that defective ones can be immediately returned.
BeagleBoard has this problem, too.[1] They have a power managment IC and shouldn't have the problem, but it's not working right.
[1] https://elinux.org/Beagleboard:BeagleBoneBlack#Improper_Powe...
> making your Pi read-only is irreversible
I understand the article is intended for people not very experienced with computing and hardware, but come on. The only fix? Irreversible? Scaring the readers bit too much, IMO.
Many programs can be made to work the same way. There are still plenty of programs that need to write longterm state to /var/lib, but you will probably need a writable partition anyway for /home, so you can just reuse that partition for /var/lib as well.
OS updates would then be handled via an A/B partitioning scheme, where you have two copies of the system partition, and when an OS update is ready to be installed, the inactive one is mounted read-write and the update written onto it.