
Recall first from OTA architecture and end-to-end security
- Campaign management selects eligible vehicles, and the vehicle agent checks whether a package can be installed locally.
- TLS protects a live connection, and package encryption can preserve confidentiality through storage and forwarding.
- Package verification uses a locally trusted public key and covers the metadata that determines what the installer does.
How an A/B update becomes active
4 min readThe secure channel is in place; this lesson answers how dual slots make an update atomic and which strategy to pick for cost and bandwidth.
Linux exposes a practical problem for any updater that writes a release in place. A successful write can leave data cached in memory before it reaches storage, and even synchronizing a file does not automatically synchronize its directory entry. The distinction is documented in fsync(2). If a release replaces several files on the running root filesystem, a reset between durable writes can leave a mix of old and new files. An A/B layout lets the installer finish writing a separate bootable release before the bootloader selects it.
A a bootable software copy, usually backed by a root filesystem partition and any release-specific boot files that must be used with it has an identity independent of the release it contains. A typical disk has two root filesystem partitions, room for the bootloader and its state, and a separate writable data filesystem. If the kernel or device tree changes with the root filesystem, the boot setup must select the matching files for each slot. A design that overwrites a shared kernel with one that works only with B can break the fallback to A, even if every byte of A's root filesystem survives.
Stage the release. With A running and known good, the updater identifies B as the inactive slot and writes the candidate there. It validates the installation according to the image format and storage design and completes the required writes. A stays available to boot if staging is interrupted.
Select B for a trial. The updater changes persistent boot selection state so that the next boot uses B with a limited trial allowance. The machine is still running A until it restarts. The bootloader must also retain a way to select A if the new selection state cannot be used.
Confirm B after startup. On reboot, the bootloader accounts for the attempt before handing control to the candidate. A health check in B confirms the release only after the required software is usable. The confirmation updates persistent boot state so that B is accepted for later boots.
Return to A if the trial fails. If B never confirms and the machine resets, the bootloader consults the remaining allowance. When the allowance is exhausted, it selects the previous good slot. A stalled kernel needs a reset before the bootloader can run again. A watchdog can provide that reset on a target that has one configured.
The atomic switch is the change in which complete release is selected for boot. Writing an image can take many writes, and selecting it is a separate operation. To survive power loss, the boot state implementation must preserve a valid selection throughout that operation. Dual partitions alone say nothing about how the bootloader stores that state. If the target also updates shared boot components, their recovery design needs its own guarantees. A slot switch covers the software selected on this machine. It does not commit an entire vehicle update in one operation.
Keep three observations distinct during testing: which root is mounted now, which slot the bootloader will try next, and which slot has passed confirmation. While A is running, the installation can already have made B the next boot target. When B first runs, its root is already mounted even though the update is still a trial. Once B is accepted, B is the current good release, and the next update can use A as its inactive destination. The letters identify locations, so the same sequence works in either direction.
How RAUC and the bootloader cooperate
3 min readThe M4 update tooling lessons cover Mender, RAUC, and SWUpdate. Mender integrates a dual-root filesystem workflow with bootloader support for trial and rollback. RAUC defines slots and their boot names in its system configuration and uses a bootloader backend for selection and confirmation. SWUpdate can install software into an inactive slot using a target-specific configuration. Its boot selection and fallback depend on the bootloader integration and the policy configured for that target. For each tool, identify who writes the candidate, who chooses the next slot, and who records that the trial succeeded.
For the RAUC exercise, use the M4 RAUC/GRUB setup on an Ubuntu 24.04 VM. Use a disposable guest disk and take a snapshot before changing its layout. The guest needs two root filesystem partitions, an initial bootable image in A, and a GRUB configuration that reads and updates the boot state used by RAUC. WSL2 works for inspecting artifacts and doing transfer calculations. Use a VM for the reboot test so that the guest actually executes the configured bootloader. The guest's boot configuration is what makes the two partitions into selectable slots.
In the RAUC system configuration, define a rootfs slot for each guest partition. Use the device entries to map the slots to the actual guest block devices, type=ext4 for ext4 slots, and bootname values that match the identifiers in GRUB. Configure bootloader=grub and ensure RAUC and GRUB use the same writable environment file. Check that each GRUB entry selects the corresponding Linux root and that the booted slot is identifiable to RAUC. Use a candidate bundle signed by a key the guest trusts, with the guest's compatible identifier and a root filesystem image for the rootfs slot class. Add a visible release marker to B before building the bundle so you can distinguish both the release and its location.
With the guest running from A, inspect its state and install the candidate. The example filename assumes the M4 bundle has been copied into the current directory. With installation activation enabled, RAUC requests that GRUB select B on the next boot.
findmnt -no SOURCE /
sudo rauc status
sudo rauc install ./candidate.raucb
sudo rauc status
Write down the running slot and the next boot target before restarting. After startup, repeat findmnt -no SOURCE / and sudo rauc status, and check the release marker. The mount source identifies the filesystem serving / on this guest. The marker identifies the software you installed there. When B passes the intended check, sudo rauc status mark-good marks the booted slot good. Running that command while still on A would confirm A. Run it only after verifying the identity and health of the system you intend to accept.
For the failure test, restore the snapshot and repeat the install with automatic confirmation disabled in the candidate. Let the guest start from B but deliberately withhold confirmation to simulate a boot that never reaches readiness. Use the VM's reset control after each unconfirmed trial until the configured boot policy selects A. The number of attempts comes from the guest's boot policy. Observe the return to A without choosing it from a boot menu or issuing a manual slot change. Capture the mount source and release marker after the return. This tests the retry and fallback path while keeping B readable enough to observe. A broken kernel would exercise that same boot selection policy after reset, with less evidence available from inside B.
{{< callout type="note" >}} If B keeps starting, check whether the bootloader actually persists the consumed attempt and whether a service is marking B good automatically. If GRUB can read its boot environment but cannot save it with the guest's storage layout, the trial budget may never expire. {{< /callout >}}
Which update format to deliver
5 min readSlot layout and update format answer different questions. The slot layout determines where the release is prepared, how it becomes active, and what can boot after failure. The format determines which bytes the server sends and what the receiver has to do to construct the release. Both a full image and a delta can produce the same image in slot B. A package update can also use a staged filesystem, but its ability to roll back then comes from the staging and boot design.
A whole-image update supplies a complete image of the filesystem or other deliverable being replaced. The server can compress it for transport. For a given supported hardware and storage layout, the same image can replace several older releases because the installer does not need their bytes to reconstruct the target. That simplifies release testing and recovery inventory. The costs are transfer size and the storage I/O to install the image. A small source change can still require shipping the entire compressed image. Streaming can reduce temporary download storage if the installer supports it.
A package update supplies selected software packages and any required dependencies. This can save bandwidth for a small application update when the underlying system is already suitable. The installer must resolve versions and account for package scripts and configuration files. If it operates on the running root, it may change files and application state in multiple steps. Rolling back a package version alone may leave dependency changes or script effects behind. To combine packages with A/B, start from a controlled filesystem in the inactive slot, apply the intended package set there, and validate the resulting release before selecting it. An inactive slot left over from an earlier release may have a different set of packages.
A differential update sends information about what changed relative to an available base. A binary delta represents how to reconstruct a particular target from particular source bytes. The receiver does extra reads and reconstruction work, and writing the target can still cost as much as writing a full image. Measure the compressed artifacts actually delivered and include common retry or full-image fallback traffic when estimating fleet transfer cost. Per-release delta generation, test coverage across supported bases, and storage for multiple artifacts can outweigh the data savings on a small fleet. On a metered fleet with a common base, the same per-device saving applies across all devices on that base.
Going deeperWhat a bsdiff delta has to prove
A classic bsdiff patch contains compressed control, difference, and extra data. The control data tells the decoder how much difference data to combine with old bytes, how many extra bytes to emit, and how to move the read position in the old file. The streams reconstruct the target in order. Patch generation and application can require substantial memory or temporary storage depending on the implementation. Measure that requirement on the receiver as well as the size of the downloaded patch.
A signed release manifest can bind the patch digest, expected base digest, target digest, and target length. Verify the patch and the base before reconstruction. A version label alone is insufficient because two byte sequences can carry the same label. For an A/B system, identify which slot or stored image holds the expected base. B may contain an older release while A contains the intended base. If the source bytes are read from a running system, use a stable source such as an immutable image or suitable snapshot. Reconstruct into B or into temporary storage, enforce the expected output size and decoder bounds, and verify the resulting target before making B bootable. Patch verification authenticates the patch bytes, while target verification checks the actual reconstruction. If the expected base is unavailable, a compatible full image can install without it.
Going deeperPersistent storage across a slot switch
The persistency interface in M12-S06A gives an application access to persistent state. On an A/B Linux target, configure the storage backend so both releases resolve the application's persistent data to the same writable filesystem outside the two root slots. For example, both roots can mount the same data volume and use it for user preferences and mutable configuration. If the backend writes only into each root filesystem, switching slots also switches which copy of the data the application sees.
The data format must survive the return trip too. Suppose B reads a preference record from A and immediately rewrites it in a format that A cannot parse. A can still boot after rollback, but its application may lose access to the preference. During the trial, keep the old representation readable, for example by writing a separate migrated copy while retaining the old one. If both releases can update the record, define which copy each reads and how changes survive a return to A. Make migration repeatable after interruption, and retain the old representation for as long as rollback to A is supported. A successful boot test and a successful data compatibility test establish different properties.
The next lesson, Preconditions, failure handling and fleet monitoring, follows the update beyond a single slot switch. It asks when a vehicle can attempt the installation and how operators know what happened across the fleet.
Key takeaways
- An A/B installer prepares the inactive slot before the bootloader selects it.
- A trial boot becomes accepted only after the configured confirmation step.
- A binary delta depends on a matching base and must produce a verified target.
- Shared persistent data must remain readable after a rollback.
Reflect
- Explain to a colleague, in two sentences: trace the running slot, next boot target, and accepted release through an A/B update.
- Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
- What surprised you when you ran the commands yourself?
On a real board
Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.
References and further reading
- Man pagefsync(2): synchronizing file data and metadata to storage
- Man pagefindmnt(8): finding the mounted root filesystem
Official documentation first. Links checked when the lesson was published.