Home Forum Blog Private Support Courses
Our courses are now on YouTube! Start Watching
Hovatek Forum OPERATING SYSTEMS Android [Tutorial] How to unpack and repack Android super.img

[Tutorial] How to unpack and repack Android super.img

[Tutorial] How to unpack and repack Android super.img

hovatek
hovatek
hovatek
Administrator
51,002
12-02-2026, 02:05 PM
#1



This guide will explain how to unpack and repack Android's super.img. This comes in handy when you wish to modify its contents, e.g., vendor.img, product.img, system.img, system_ext, etc., or change it from Read-only (RO) to Read-write (RW)

Note
The contents of your super.img might vary from the example super.img used in this guide.

Requirements


Unpacking super.img



  1. Launch the terminal app from the folder where the system.img is located and run the following commands

    Code:

    simg2img super.img super.ext4.img lpunpack super.ext4.img

  2. You should now see the contents of the super.img


Modifying system.img, vendor.img, product.img etc



Note:Virtual machines might encounter problems with symlinks when working in the Shared Directory (/mnt), so your working folder should be somewhere else, e.g., the Desktop, Documents, etc in Ubuntu.

  1. To modify system_a.img (for example), you run the following commands{

    Code:

    resize2fs system_a.img 2G mkdir system sudo mount -t ext4 -o loop system_a.img system

  2. The system folder should now be populated with files and folders.
  3. Make your desired modifications (preferably by replacing files via sudo commands in the terminal), then run the following commands when done:

    Code:

    sudo umount system e2fsck -yf system_a.img resize2fs -M system_a.img e2fsck -yf system_a.img



Repacking super.img



  1. Get the file sizes of each file that's to be repacked into super.img (take note of each)

    Code:

    stat -c '%n %s' system_a.img stat -c '%n %s' system_b.img stat -c '%n %s' system_ext_a.img stat -c '%n %s' system_ext_b.img stat -c '%n %s' product_a.img stat -c '%n %s' product_b.img stat -c '%n %s' vendor_a.img stat -c '%n %s' vendor_b.img


  2. Use the command below to repack super.img (Do NOT copy the command below verbatim; see the explanation below the command to understand how to modify it accordingly)

    Code:

    lpmake \ --output ./super.new.img \ --sparse \ --metadata-size 65536 \ --super-name super \ --metadata-slots 2 \ --device super:5297405952 \ --group slot_a:4001886208 \ --group slot_b:366387200 \ --partition product_a:none:977362944:slot_a --image product_a=./product_a.img  \ --partition product_b:none:0:slot_b --image product_b=./product_b.img \ --partition vendor_a:none:335638528:slot_a --image vendor_a=./vendor_a.img \ --partition vendor_b:none:0:slot_b --image vendor_b=./vendor_b.img \ --partition system_ext_a:none:717447168:slot_a --image system_ext_a=./system_ext_a.img \ --partition system_ext_b:none:0:slot_b --image system_ext_b=./system_ext_b.img \ --partition system_a:none:1971437568:slot_a --image system_a=./system_a.img  \ --partition system_b:none:366387200:slot_b --image system_b=./system_b.img

    Explanation
    • --output: Give the repacked super image your preferred name
    • --sparse: Outputs a sparse image for fastboot flashing
    • --metadata-size: Should be a multiple of 512. You may leave it as 65536
    • --super-name: You may leave it as super
    • --metadata-slots: 1 is for A-only (Non-A/B) devices while 2 is for A/B devices
    • --device: The format is super:[filesize] where filesize is the size of the super.ext.img. You can obtain this from the scatter file (for MediaTek) using a HEX calculator or using the command:
      Code:

      ls -al
    • --group You are to group the partitions (give groups a name of your choosing). A-Only devices will have just 1 group, while A/B devices would have two groups. In this example, I created 2 groups: slot_a and slot_b
      • --group slot_a: The sum of the sizes of *_a files that are to be repacked into super.img (in this example, that's system_a.img + system_ext_a.img + product_a.img + vendor_a.img)
      • --group slot_b: The sum of the sizes of *_b files that are to be repacked into super.img (in this example, that's system_b.img + system_ext_b.img + product_b.img + vendor_b.img)
    • --partition: This is the information of each file to be packed into system.img.
      For example --partition product_a:none:974548992:main --image product_a=./product_a.img
      In this case, product_a is the partition name, none could be either readonly (for RO) or none (for RW), 974548992 is the file size, product_a.img is the file name, slot_* is the corresponding group name

  3. You can now flash your super.img

Important Notice
  • Some brands (or chipsets like Unisoc) might require you to generate corresponding chained vbmeta like vbmeta.img, vbmeta_system.img and vbmeta_vendor.img
  • For devices (usually Android 12+) with EROFS (Read-only), follow the steps @ https://www.hovatek.com/forum/thread-46941.html to convert the extracted partition's files from EROFS to EXT4
  • If you preview your repacked super image in 7zip or Winrar and notice system_a.ext/system_b.ext, product_a.ext/product_b.ext or vendor_a.ext/vendor_b.ext instead of system_a.img/system_b.img, product_a.img/product_b.img or vendor_a.img/vendor_b.img then the problem is from resize2fs. You may skip the resize2fs -M commands
This post was last modified: 09-03-2026, 09:47 PM by hovatek.

Learn MediaTek, Unisoc / Spreadtrum (SPD) and Qualcomm Software Repairs @ https://www.hovatek.com/training
Note!
We have a reply schedule for Forum Support. Please try Private Support if you can't wait.
Users browsing this thread:
 1 Guest(s)
Users browsing this thread:
 1 Guest(s)
WhTlYt