[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# OTA for A/B devices with dynamic partitions\n\nAndroid 10 supports\n[dynamic partitions](/docs/core/ota/dynamic_partitions), a userspace partitioning\nsystem that can create, resize, and destroy partitions during over-the-air (OTA) updates.\n\nThis page describes how to resize dynamic partitions during an update for A/B devices that\nlaunched with dynamic partitions support, for devices running **Android 9 and\nlower**.\n\nBackground\n----------\n\n\nThere's one `super` partition on the device. This\npartition isn't slot suffixed. The block device must exist along\nwith the `blk_device` entry for `/misc` in\n`fstab`. For example, if the `fstab` file lists: \n\n```text\n/dev/block/bootdevice/by-name/misc /misc # Other fields\n```\n\n\nThen the block device for `super` must exist in\n`/dev/block/bootdevice/by-name/super`, but the\n`super` partition doesn't need to be listed in the\n`fstab` file.\n\n\nIn the `super` partition, there are two\n*metadata slots* , numbered 0 and 1, corresponding to\nA/B slots for partitions. In this page, the metadata slots are\ncalled Metadata S (source) and Metadata T (target). Similarly,\npartitions are referred to as `system_s`,\n`vendor_t`, and so on.\n\n\nBefore the upgrade, Metadata S contains the information for the\ndynamic partitions being used (typically, `system_s`,\n`vendor_s`, `product_s`, and so on). The system\nreads the extents for these partitions during the update, so they\ncan't be deleted.\n\n\nPartitions belong to *update groups* . See\n[Implementing\nDynamic Partitions](/docs/core/ota/dynamic_partitions/implement) for details.\n\n\nAn example of metadata on a device is as follows.\n\n- Metadata 0\n - Group `foo_a`\n - Partition `system_a`\n - Partition `product_services_a`\n - Other partitions updated by Foo\n - Group bar_a\n - Partition `vendor_a`\n - Partition `product_a`\n - Other partitions updated by Bar\n - Group `foo_b` (leftover from previous upgrade)\n - Group `bar_b` (leftover from previous upgrade)\n- Metadata 1\n - Group `foo_a` (leftover from previous upgrade)\n - Group `bar_a` (leftover from previous upgrade)\n - Group `foo_b`\n - Partition `system_b`\n - Partition `product_services_b`\n - Other partitions updated by Foo\n - Group `bar_b`\n - Partition `vendor_b`\n - Partition `product_b`\n - Other partitions updated by Bar\n\n\nYou can use the `lpdump` tool (source code under\n`system/extras/partition_tools`) to dump the metadata on\nyour device. For example: \n\n lpdump --slot 0 /dev/block/bootdevice/by-name/super\n lpdump --slot 1 /dev/block/bootdevice/by-name/super\n\nUpdate flow\n-----------\n\n1. **Initialize the `super` partition metadata.**\n 1. Load the extents for the source dynamic partitions from Metadata S. Let M be the loaded metadata.\n 2. Remove target groups and partitions (for example, `foo_t`, `bar_t`) from M so that M contains only partitions and groups with the `_s` suffix.\n 3. Add target groups and partitions according to the `dynamic_partition_metadata` field in the update manifest. \n The size of each partition can be found in `new_partition_info`.\n 4. Write M to Metadata T.\n 5. Map the added partitions on the device mapper as writable.\n2. **Apply the update on the block devices.**\n 1. If necessary, map the source partitions on the device mapper as read only. This is necessary for sideloading because the source partitions aren't mapped prior to the update.\n 2. Apply a full or delta update to all block devices at the target slot.\n 3. Mount the partitions to run the post-install script, and then unmount the partitions.\n3. **Unmap the target partitions.**\n\n| **Note:** The extents for both source and target dynamic partitions span across the entire `super` partition. As a result, you must load the source metadata so that these extents aren't used as part of any target partitions.\n\n\nBefore and after the update, the following system properties should have\nthe respective values: \n\n```scdoc\nro.boot.dynamic_partitions=true\nro.boot.dynamic_partitions_retrofit=true\n```\n\nAdd groups and partitions to the update manifest\n------------------------------------------------\n\n\nWhen performing an OTA update on an A/B device with dynamic partitions,\nor an A/B device that is adding support for dynamic partitions, you\nneed to add groups and partitions to the update manifest. The snippet\nbelow shows additional information on the update manifest to support\ndynamic partitions. See\n[update_metadata.proto](https://android.googlesource.com/platform/system/update_engine/+/android16-release/update_metadata.proto)\nfor detailed documentation on each field. \n\n```scdoc\nmessage DeltaArchiveManifest {\n optional DynamicPartitionMetadata dynamic_partition_metadata;\n}\n\nmessage DynamicPartitionMetadata {\n repeated DynamicPartitionGroup groups;\n}\n\nmessage DynamicPartitionGroup {\n required string name;\n optional uint64 size; // maximum size of group\n repeated string partition_names;\n}\n```"]]