AOSP Foundations
2 min read

Virtual A/B Partitions

Explore how Virtual A/B combines the safety of seamless updates with the storage efficiency of a single partition.

While traditional A/B Seamless Updates solved the problem of bricked phones and long loading screens, they introduced a massive new problem: wasted storage.

If the core OS takes up 4GB, duplicating it to create Slot A and Slot B means reserving 8GB of the user's expensive physical flash storage exclusively for the operating system. For low-end phones with only 32GB of total storage, this overhead was unacceptable.

To solve this, Google introduced Virtual A/B Partitions in Android 11.

The Best of Both Worlds

Virtual A/B attempts to provide the background, seamless update experience of a dual-slot A/B device, while only consuming the physical storage space of a single-slot device.

It achieves this by heavily utilizing the Dynamic Partitions (super partition) architecture.

How Virtual A/B Works

In a Virtual A/B configuration, there are no duplicate physical partitions. There is only one system_a partition physically residing inside the super container.

When an OTA update arrives:

  1. Snapshotting: Instead of flashing a full duplicate partition, the update engine takes a microscopic snapshot of the current system partition using a kernel feature called dm-snapshot.
  2. Copy-on-Write (COW): The update engine begins applying the new update. Instead of modifying the actual system partition (which is currently running the phone), it writes the changed blocks to a temporary file in the /data partition called a COW file.
  3. Virtual Merge: When the user reboots, the bootloader utilizes the dm-snapshot driver to virtually merge the original system partition with the COW file on the fly. The OS boots seamlessly into the updated framework.
  4. Background Commit: Once the phone has fully booted and verified the update is stable, a background daemon slowly merges the COW file permanently into the physical system partition, freeing up the temporary space.
# You can check if your device supports Virtual A/B via properties
adb shell getprop ro.virtual_ab.enabled
# Output: true

Compression and Efficiency

Starting with Android 12, Google introduced Virtual A/B with Compression (VABC). Because the update blocks written to the COW file are temporarily stored on the user's /data partition, they eat into the user's free space during the update phase. VABC aggressively compresses these blocks, reducing the temporary storage requirement by over 50%, making seamless updates possible even on severely storage-constrained budget devices.