Why A/B partitioning?
In embedded systems, failed updates can brick devices. An A/B layout solves this by maintaining two root filesystems:
- Slot A — active rootfs
- Slot B — standby rootfs for next update
When an update succeeds, the bootloader switches to the new slot. If boot fails, it rolls back to the last known good version.
This approach presupposes, that slot A and slot B have the same size of the partition, which can be sometimes tricky in embedded systems, when the resources are limited.
Another approach is, to create partitions for a small rescue system and a bigger partition for the normal running system.
Example Partition Layout
| Partition | Type | Purpose |
|---|---|---|
| p1 | FAT32 | /boot_A (kernel, cmdline, bootloader) |
| p2 | ext4 | rootfs A |
| p3 | FAT32 | /boot_B (kernel, cmdline, bootloader for rescue system) |
| p4 | ext4 | rootfs_B |
| p5 | ext4 | data / configuration |
Practical Example
This setup is demonstrated in two rpi-image-genexample projects:
- https://github.com/interelectronix/rpi-image-gen-projects/blob/main/deb12-cm5-rescue/README.md
- https://github.com/interelectronix/rpi-image-gen-projects/blob/main/deb12-cm5-ix-base/README.md
The first one creates the rescue system and the second one combines the rescue system with another running system, adjusting partition labels in cmdline.txt and fstab.
Managing update
You can mount the inactive system partition manually to update configurations, applications, or system components.
For production systems, updates are typically managed via SWUpdate, which automates this process safely.
Integration with SWUpdate
SWUpdate natively supports dual-rootfs (A/B) update strategies.
Partitions and update logic are defined directly in the sw-description file.
This approach ensures atomic system updates with built-in rollback safety — an essential feature for headless or remote devices, where manual recovery isn’t feasible.
Articles in this series
- Building a Production-Ready Linux for Raspberry Pi Compute Module 5
- From Stock OS to Production Platform
- Customizing Raspberry Pi OS with rpi-image-gen
- System Robustness — Designing an A/B Root Filesystem Layout
- Provisioning — Automating First Boot with rpi-sb-provisioner
- OTA and Lifecycle — Software Updates with SWUpdate
Sources
- rpi-image-gen: https://github.com/raspberrypi/rpi-image-gen
- rpi-sb-provisioner: https://github.com/raspberrypi/rpi-sb-provisioner
- SWUpdate: https://github.com/sbabic/swupdate
- swugenerator: https://github.com/sbabic/swugenerator