Android has two update mechanisms: A/B (seamless) updates and non-A/B updates. To reduce code complexity and enhance updateability, Android 11 unifies the two mechanisms. The new update mechanism, virtual A/B, combines the advantages of both predecessors by bringing seamless updates to all devices while minimizing the cost of storage.
- Virtual A/B updates are seamless like A/B updates. Virtual A/B updates minimize the time that a device is offline and unusable.
- Virtual A/B updates can be rolled back. If the new OS fails to boot, devices automatically roll back to the previous version.
- Virtual A/B updates use minimum extra space by duplicating only partitions used by the bootloader. Other updateable partitions are snapshotted.
This section explains some terminology and technology that support virtual A/B.
Device-mapper is a Linux virtual block layer used often in Android. With
/system are a stack of layered devices:
- At the bottom of the stack is the physical super partition (for example,
- In the middle is a
dm-lineardevice, specifying which blocks in the super partition form the given partition. This appears as
/dev/block/mapper/system_[a|b]on an A/B device, or
/dev/block/mapper/systemon a non-A/B device.
- Finally, a
dm-veritydevice is created for verified partitions. This device verifies that blocks on the
dm-lineardevice are signed correctly. It appears as
/dev/block/mapper/system-verityand is the source of the
Here's a diagram of the stack under the
/system mount point.
Diagram 1. Stack under the /system mount point
Virtual A/B relies on
dm-snapshot, a device-mapper module for snapshotting
the state of a storage device. When using
dm-snaphot, there are four devices
- The base device is the device that is snapshotted. On this page, the base device is always a dynamic partition, such as system or vendor.
- The copy-on-write (COW) device is used to log changes to the base device. It can be any size, but it must be big enough to accommodate all changes to the base device.
- The snapshot device is created using the
snapshottarget. Writes to the snapshot device are written to the COW device. Reads from the snapshot device read either from the base device or the COW device, depending on whether the data being accessed has been changed by the snapshot.
- The origin device is created using the
snapshot-origintarget. Reads to the origin device read directly from the base device. Writes to the origin device write directly to the base device, but the original data is backed up by writing to the COW device.
Diagram 2. Device mapping for dm-snapshot