Rooting, Flashing, & Bootloader Exploits

How to Resize Dynamic Partitions for Custom System Images on Android 10+: A Practical Walkthrough

Google AdSense Native Placement - Horizontal Top-Post banner

Introduction to Dynamic Partitions on Android 10+

Since Android 10, Google introduced a significant architectural change with Project Treble, moving towards a ‘Dynamic Partitions’ system. This system replaces traditional fixed-size partitions like system, vendor, and product with logical partitions residing within a single ‘super’ partition (super.img). This allows for more flexible allocation of space, enabling features like seamless A/B updates and reducing the barrier for Generic System Images (GSIs).

However, this flexibility comes with new challenges for custom ROM developers and enthusiasts. When installing custom ROMs or GSIs, especially those with different size requirements than the stock images, the default logical partition sizes within your device’s super.img might be insufficient. For instance, a GSI might require a larger system partition than your stock firmware allocates, leading to ‘not enough space’ errors during flashing. This guide will walk you through the process of rebuilding and resizing your super.img to accommodate custom system images on Android 10+ devices.

Prerequisites and Tools

Before embarking on this journey, ensure you have the following prerequisites and tools ready:

Unlocked Bootloader & ADB/Fastboot

  • Your device’s bootloader must be unlocked. This is a critical first step for any custom firmware modification.
  • You need ADB (Android Debug Bridge) and Fastboot tools installed and properly configured on your computer. These are typically part of the Android SDK Platform Tools.

Essential Tools for Dynamic Partition Manipulation

You’ll need specific tools, often compiled from AOSP source, to work with dynamic partitions:

  • lpmake: Used to create a super.img from individual partition images and a configuration file.
  • lpunpack: Used to extract individual partition images from an existing super.img.
  • fastboot: The standard tool for flashing partitions to your device.

These tools can often be found pre-compiled in various Android modding forums or by compiling them from the Android source tree yourself. Ensure they are added to your system’s PATH or are located in the directory where you’ll be executing commands.

Understanding Your Device’s Super Partition Layout

The first step is to understand the current layout of your device’s super partition. You’ll typically obtain this by extracting the super.img from your device’s factory image. If a super.img is not directly available, you might find a super_empty.img along with individual partition images (system.img, vendor.img, etc.) which can be used to reconstruct it.

  1. Obtain Your Device’s Factory Image or Dump

    Download the full factory image for your specific device model and Android version. Inside, look for a super.img or individual partition images. If your device uses A/B slots, you might see super_a.img or super_b.img.

  2. Extract and Inspect the Super Partition

    Use lpunpack to examine the contents and layout of your super.img. Navigate to the directory containing super.img in your terminal and run:

    lpunpack --sparse --output_dir extracted_super super.img

    This command will extract the logical partitions (like system.img, vendor.img, product.img) into the extracted_super directory. Inspecting these files will give you an idea of the default sizes and the partitions present.

Planning Your New Partition Layout

Now, you need to decide on the new sizes for your dynamic partitions. This is crucial for installing your custom ROM or GSI. The new sizes should be large enough to accommodate the images you intend to flash. Typically, a GSI requires a system partition of around 3-5 GB, and a vendor partition that matches the stock firmware’s requirements or the GSI’s specific needs.

  • Identify the sizes of the system.img, vendor.img, etc., from your custom ROM or GSI. You can check the file size of these images.
  • Allocate additional space for future updates or expansion, but be mindful of the total available space on your device.
  • Remember that the super.img has a maximum total capacity, which is dictated by your device’s hardware. Exceeding this will cause flashing errors.

Step-by-Step: Rebuilding Your Super Partition

Step 1: Obtain Custom Partition Images

Extract the system.img, vendor.img, product.img, etc., from your custom ROM ZIP file or GSI package. Place these images in a working directory on your computer.

Step 2: Create a Configuration XML for lpmake

lpmake requires a configuration XML file that defines the structure and sizes of the dynamic partitions. This XML specifies partition groups, their maximum sizes, and the logical partitions within them. A typical lpmake manifest might look like this:

<?xml version="1.0" encoding="UTF-8"?> <lpmake> <super_partition_groups> <group name="main" max_size="YOUR_TOTAL_SUPER_SIZE_IN_BYTES" /> </super_partition_groups> <super_partitions> <partition name="system_a" size="SYSTEM_PARTITION_SIZE_IN_BYTES" readonly="true" group="main" /> <partition name="vendor_a" size="VENDOR_PARTITION_SIZE_IN_BYTES" readonly="true" group="main" /> <partition name="product_a" size="PRODUCT_PARTITION_SIZE_IN_BYTES" readonly="true" group="main" /> <!-- Add other partitions like odm_a, system_ext_a as needed --> </super_partitions> </lpmake>

Replace YOUR_TOTAL_SUPER_SIZE_IN_BYTES with the total maximum size you want for your super.img (e.g., 8GB = 8000000000 bytes). For individual partition sizes, use values appropriate for your custom ROM images. Ensure you account for A/B slots if your device supports them (e.g., system_a and system_b partitions).

Step 3: Use lpmake to Create the New super.img

With your custom partition images and the XML configuration file (let’s call it new_super_config.xml), you can now use lpmake. The command structure typically looks like this:

lpmake --metadata 4 --partition-config new_super_config.xml --image system_a=path/to/your/system.img --image vendor_a=path/to/your/vendor.img --output super_new.img

Let’s break down the arguments:

  • --metadata 4: Specifies the number of metadata copies (usually 2 or 4, 4 is safer for A/B devices).
  • --partition-config new_super_config.xml: Points to your XML configuration file.
  • --image system_a=path/to/your/system.img: Maps your system.img file to the logical partition system_a defined in the XML. Repeat for all partitions you want to include in the initial super_new.img.
  • --output super_new.img: The name of the new super image file to be created.

It’s important to note that you don’t necessarily have to include all partition images in the `lpmake` command; often, you just define the partition slots, and then flash the actual `.img` files separately. However, for a complete `super.img` to flash, it’s safer to include the images.

# Example if you want to include images directly in super.img (less common for custom ROMs, often just flash empty super then system/vendor) lpmake --metadata 4 --group main:8000000000 --partition system_a:readonly:4000000000:main --image system_a=system.img --partition vendor_a:readonly:1000000000:main --image vendor_a=vendor.img --sparse --output super_new.img

In this example, main:8000000000 defines a group named ‘main’ with a max size of 8GB. The system_a and vendor_a partitions are allocated specific sizes within this group.

Step 4: Flash the New super.img

Reboot your device into Fastboot mode. Then, flash your newly created super_new.img:

fastboot flash super super_new.img

This step will overwrite your device’s existing super partition with your resized layout. This is a critical step; ensure your super_new.img is correctly built to avoid bricking your device.

Step 5: Flash Your Custom System Image(s)

With the new super partition layout in place, you can now flash your custom system images onto the resized logical partitions. These will automatically utilize the new sizes you’ve defined.

fastboot flash system system.img fastboot flash vendor vendor.img fastboot flash product product.img fastboot reboot

Flash all necessary dynamic partition images (`system`, `vendor`, `product`, `odm`, `system_ext`) that are part of your custom ROM or GSI. After flashing, reboot your device to experience your custom ROM.

Troubleshooting Common Issues


  • Android Mobile Specs & Compare Directory

    Are you researching mobile hardware properties, processor SoCs, GPU chipsets, or RAM configurations? Access our complete specs catalog to compare up to 5 devices side-by-side!

    Compare Devices Specs →
Google AdSense Inline Placement - Content Footer banner