- 问题平台:Android Q,无AB update,开启dynamic partition,机器专门做OTA升级压测,同一个OTA包在多个机器上升级,仅这台机器升级失败,其他机器升级没问题,且这台机器能正常开机和操作。
- 看OTA升级的log,异常为扩展system分区失败导致
[liblp]Partition vendor will resize from 0 bytes to 217198592 bytes
[liblp]Not enough free space to expand partition: system
Failed to resize partition system to size 1719984128.
script aborted: assert failed: update_dynamic_partitions(package_extract_file("dynamic_partitions_op_list"))
E:Error in @/cache/recovery/block.map (status 7)
- 对比正常的log,分区大小是合法的,问题也就进一步证明与机器关联
[liblp]Partition vendor will resize from 0 bytes to 217198592 bytes
[liblp]Partition system will resize from 0 bytes to 1719984128 bytes
[liblp]Updated logical partition table at slot 0 on device /dev/block/by-name/super
- 在异常和正常的机器上执行lpdump,确认异常的机器多了一个scratch分区
------------------------
Name: scratch
Group: default
Attributes: none
Extents:
0 .. 559463 linear super 3639448
------------------------
-
从Google信息看,adb remount时,就会创建这样的一个分区,
https://source.android.google.cn/devices/tech/ota/dynamic_partitions/implement?hl=zh-cn#adb-remount -
通过如下代码可以确认OTA不会删除scratch分区(属于default group),继而导致异常
-
综上,操作上要复现问题,就是关avb,并adb remount_all之后操作system或vendor分区,填足够多的数据,然后在未关闭AVB的情况,直接进行OTA升级,就能够复现问题。
-
恢复的方法也就是如下,操作完毕之后,重新使能AVB就可。
adb disable-verity -> adb remount(创建scratch分区用于存放文件)
-> adb enable-verity(删除scratch分区,恢复系统镜像) -
附上正常异常的lpdump命令执行结果
异常的
Metadata version: 10.0
Metadata size: 516 bytes
Metadata max size: 65536 bytes
Metadata slot count: 2
Partition table:
------------------------
Name: scratch
Group: default
Attributes: none
Extents:
0 .. 559463 linear super 3639448
------------------------
Name: vendor
Group: group_oem
Attributes: readonly
Extents:
0 .. 424215 linear super 2048
------------------------
Name: system
Group: group_oem
Attributes: readonly
Extents:
0 .. 3185727 linear super 426264
------------------------
Block device table:
------------------------
Partition name: super
First sector: 2048
Size: 2150629376 bytes
Flags: none
------------------------
Group table:
------------------------
Name: default
Maximum size: 0 bytes
Flags: none
------------------------
Name: group_oem
Maximum size: 2146435072 bytes
Flags: none
------------------------
正常的
/cache # lpdump
Metadata version: 10.0
Metadata size: 440 bytes
Metadata max size: 65536 bytes
Metadata slot count: 2
Partition table:
------------------------
Name: system
Group: group_oem
Attributes: readonly
Extents:
0 .. 3185727 linear super 2048
------------------------
Name: vendor
Group: group_oem
Attributes: readonly
Extents:
0 .. 424215 linear super 3188736
------------------------
Block device table:
------------------------
Partition name: super
First sector: 2048
Size: 2150629376 bytes
Flags: none
------------------------
Group table:
------------------------
Name: default
Maximum size: 0 bytes
Flags: none
------------------------
Name: group_oem
Maximum size: 2146435072 bytes
Flags: none
------------------------