78 points · by tdrnd · 9y ago · 43 comments
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.
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.
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.
I certainly wouldn't want to just unplug them from power.
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.