Jump to content

Android dynamic partitions

From postmarketOS Wiki
Revision as of 00:33, 9 May 2022 by Flamingradian (talk | contribs) (initial documentation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Devices running Android 10 and later versions implement the dynamic partitioning scheme. With dynamic partitioning, multiple logical partitions are defined in a single "super" partition. They behave very much like Linux LVM, being flexible and easy to change around. However, dynamic partitioning follows a different format from LVM.

PostmarketOS does not support dynamic partitioning out of the box, but it can through some changes to the device-specific package.

Adding support for dynamic partitions to your port

There are a few changes you need to make to the device package:

  • add make-dynpart-mappings to the dependencies in the APKBUILD
  • set deviceinfo_super_partitions in deviceinfo to a certain value
  • regenerate the checksums
  • rebuild the device package and everything related to updating it

There is no single correct value for deviceinfo_super_partitions, hence the need for it as a configuration value. Below is a guide to determine the appropriate value for deviceinfo_super_partitions.

Retrofit or single super partition?

The super partitions are different for devices that launched before Android 10, called retrofit devices, and devices launching with Android 10 or higher.

Retrofit Devices

For retrofit devices, two physical partitions act as the super partitions: system_a and system_b. The appropriate line in deviceinfo would be:

deviceinfo_super_partitions="PARTLABEL=system_a PARTLABEL=system_b"

Special cases

On retrofit devices, the device manufacturer has the option to specify different super partitions. If your device has a https://github.com/LineageOS/android_device_* repository, you can look for the value of BOARD_SUPER_PARTITION_METADATA_DEVICE in the board configuration (i.e. BoardConfig*.mk). If the value is different from "system", then you should replace both occurrences of "system" in deviceinfo_super_partitions with it.

Devices launching with Android 10

For devices launching with Android 10 have a single super partition called "super". If your device has A/B seamless update, or you are not sure, then you should specify the same super partition twice, for example:

deviceinfo_super_partitions="PARTLABEL=super PARTLABEL=super"

Flashing to a device with dynamic partitioning

Dynamic partitions are only supposed to be flashed in fastbootd, as opposed to the bootloader fastboot. To get to fastbootd from the bootloader fastboot, run:

$ fastboot reboot fastboot

Since fastbootd is in userspace, it will most likely be inaccessible on the slot where you flash the postmarketOS kernel. If you want to keep flashing to dynamic partitions, you should consider flashing the kernel to the inactive slot so you still have a working fastbootd.

See also