r/embeddedlinux • u/cdokme • May 15 '26
Sanity check: Embedded Linux storage architecture for a remote device (A/B updates, OverlayFS, strict RO RootFS)
Hey folks,
I'm working on the OS architecture for an ultra-remote, autonomous gateway device. Once it is deployed, physical access is no more possible and communication bandwidth is quite low.
We use Yocto to build our BSP. I'd love to get a sanity check from the community on our storage and filesystem architecture before we lock it in.
Here is the rundown of our approach:
1. Hardware & Boot Hierarchy We have an external hardware MCU that controls the boot pins to provide a 3-tier failsafe:
- Tier 1 (Golden Rescue): QSPI Flash. Strictly read-only monolithic image (bootloader, minimal kernel, initramfs). Only booted if block devices completely fail.
- Tier 2 (Primary Prod): eMMC.
- Tier 3 (Dev/Secondary Fallback): SD Card.
2. Partition Layout Both the eMMC and SD card use an identical 4-partition block layout:
BOOT(FAT32)RootFS-A(EXT4)RootFS-B(EXT4)Data(EXT4 - persistent storage for logs/payload data)
3. Filesystem Permissions & State Management
- Production:
RootFS-AandRootFS-Bare strictly Read-Only by default. (The inactive RootFS slot and the BOOT partition only become temporarily writable during an OTA update). - Development: To keep engineering velocity high, we tweak the kernel bootargs via the U-Boot console to mount the active RootFS as Read-Write for local testing and application/library deployment.
- Volatile Data:
/varand/tmpare mounted to RAM (tmpfs) to save flash wear. Critical post-mortem crash logs are explicitly written to theDatapartition before a watchdog reboot. - Persistent State: We use OverlayFS for paths like
/etcand/home. Theupperdirlives on theDatapartition of the currently active boot medium.
4. Mitigating A/B Update Configuration Drift Because we rely on Delta OTAs (due to the narrow bandwidth), we ran into the classic OverlayFS trap: if Slot B boots a newly updated app, it might read an outdated configuration schema left behind in the /etc overlay by Slot A.
- Our Fix: We enforce schema versioning in the directory structure itself. Apps read their configs from paths like
/etc/myorg/app/v2.1.0/config.yaml. This allows old and new schemas to safely coexist in the persistent overlay.
My questions for the community:
- Are there any hidden traps with the OverlayFS
upperdirliving on anext4partition that is susceptible to sudden power loss, assuming we mount it with aggressivefsckauto-repair flags? - Is bypassing the RO RootFS via U-Boot for development a common practice, or are we asking for Dev/Prod parity trouble down the line?
- Does anyone see a glaring flaw in how we are handling the A/B configuration drift using versioned directory paths?
Appreciate any ruthless critiques or advice you can offer!
7
u/Ok-Adhesiveness5106 May 15 '26
Adding a read-only file system to image features doesn't make the file system "strictly" read-only. I can remove your fallback SD card, put it in my PC, make changes to it, and boot from your fallback MMC device, and no one has to know about it. You will continue mount the file system as read-only but changes to it were made offline, this is a classic situation of no offline protection. Consider using kernel features like dm-verity to make your FS truly read only.
You can also use dm-crypt to encrypt your file system, make sure the key management is shifted to a trust store like OPTEE or CAAM in NXP.
Consider signing your boot container that goes into QSPI flash, and make sure that the ROM bootloader verifies it. For example, if you are on NXP, then take a look into HAB, which is interesting, or take a look into the TBBR framework from Arm.
Is the kernel fitImage that you have in boot partition is signed? If not consider signing that as well.
5
u/jeroof May 15 '26
If your rootfs slots are read only, consider using erofs or squashfs, which make it easier to assess the rootfs content and metadata integrity/authenticity, even from bootloader, and sometimes allow for faster boot. This approach may or may not impact your delta ota updates efficiency depending on how it’s implemented.
2
u/PurepointDog May 15 '26
Honestly seems pretty solid. Config versioning was not something I'd thought of.
If you're worried at all about power losses, btrfs instead of ext4 may be a really good tweak.
2
u/andrewhepp May 15 '26
Any filesystem can become corrupted. The risks are much higher with a writable filesystem, even if it's journaled. I have found ext4 to be very resilient, but what you're describing doesn't sound like it would achieve any higher reliability than your standard desktop computer or server.
I think this is mostly a moot point, since best practices are to have a variety of automated tests, including many that are independent of any developer machines and some that are run end-to-end in a mirror of the production deployment.
There are two related concepts here that I feel are being muddled in your explanation of the "configuration drift" issue you're trying to solve.
The issue you are describing is because you are not fully specifying the post-update state of your device. This is separate from whether the update mechanism transfers that full state, or only the delta from your current state.
It is possible for me to update only the file /etc/network/interfaces, by sending the full file to the device regardless if whether that matches its current contents.
It is also possible for me to define the end state of the entire block device, and if the only change is a couple of blocks corresponding to a line in /etc/network/interfaces, those blocks are all that get sent over-the-air.
So I would object to the idea that managing bandwidth requires not fully defining the post-update state of the device, and it sounds like you may want to consider whether that is appropriate.
other thoughts
This could be a reasonable or even a good design, but I don't think you've made a case that it will be more reliable than a standard desktop linux distro. For instance, it sounds like your ultimate fallback is that you boot from read-only QSPI. What happens then? Will you be able to achieve operational objectives? If so, why not just always boot from QSPI? Are you confident the MCU will always be correct about the boot pins? What is the "liveness test"? What additional resilience is provided by the SD card? If you screw up the MMC, why do you think you won't just screw up the SD card too? What lives on your boot partition, and are you ever going to update that? It's not mirrored. Is it fat32? Are you ever going to upgrade the kernel? What if the running kernel version is incompatible with modules on the rootfs?
Without knowing the full constraints, it's hard to say what exactly is an appropriate level of engineering to put into this. But those are the kinds of things I would be considering if I wanted to increase the reliability.
2
u/shoragan May 15 '26
Be careful with persistent overlayfs for /etc stored on the data partition. Any file you modify (even by accident) is copied to the upperdir, so any new configuration versions you deploy via OTA will not be visible. While you can do cleanup with scripts on update installation, it's still error prone.
Consider using a tmpfs overlay and explicitly generating/restoring config files from the data partition during early boot.
Another risky choice is using a shared FAT partition for boot. FAT can be corrupted if you loose power or crash while writing to it.
What are you using for OTA?
2
u/Dezgeg May 15 '26
You don't necessarily need to mess with U-Boot variables to change rootfs to read-write, just running `mount -o remount,rw /` is enough.
3
u/jeroof May 15 '26 edited May 15 '26
If the eMMC is mlc/tlc flash, a page failure occurring on the writable data partition or during ota has the potential to damage mission critical data on one of the other partitions, e.g the fat32 one. For this reason many eMMC drives also support being switched to pseudo slc mode.
3
u/jeroof May 15 '26
I have used version specific config slots quite a few times. This is great for handling config schema evolutions, and rollbacks to previous firmware versions. In my case I always abstracted the config using an implementation agnostic format (e.g. openwrt’s uci), generating actual config files to tmpfs at each boot, which made it convenient to perform configuration schema migrations when needed (using a schema revision tag). Also garbage collecting old config folders.