Overview of Virtual A/B

https://source.android.google.cn/devices/tech/ota/virtual_ab

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.

Note: Virtual A/B will be a GMS requirement on devices launching with Android 11 (subject to change).

Background

This section explains some terminology and technology that support virtual A/B.

Device-mapper

Device-mapper is a Linux virtual block layer used often in Android. With dynamic partitions, partitions like /system are a stack of layered devices:

  • At the bottom of the stack is the physical super partition (for example, /dev/block/by-name/super).
  • In the middle is a dm-linear device, 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/system on a non-A/B device.
  • Finally, a dm-verity device is created for verified partitions. This device verifies that blocks on the dm-linear device are signed correctly. It appears as /dev/block/mapper/system-verity and is the source of the /system mount point.

Here's a diagram of the stack under the /system mount point.

Paritition stacking underneath system

Diagram 1. Stack under the /system mount point

dm-snapshot overview

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 in play:

  • 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 snapshot target. 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-origin target. 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.

Device mapping for dm-snapshot

Diagram 2. Device mapping for dm-snapshot

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值