• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[GUIDE] OTA Tools LPUnpack

Search This thread

bynarie

Senior Member
Aug 2, 2013
298
140
Hilliard OH
OnePlus 7T
Please see this URL https://android.googlesource.com/platform/build.git/+/eec4a7cba4face3370acb6293ab357879920b467 and this for more information.

Hi everyone. I'm surprised I havent seen a thread about ota tools yet and lpunpack. This zip file contains a lot of useful tools for modifying super.img and making super.img as well as other tools found in other toolkits. This was just compiled using aosp master. The most useful function is the lpunpack tool which can extract a super.img into system, vendor, odm and product images.


Browse individual files

Download HERE
  • Extract super.img from device

Code:
adb shell
Code:
su
Code:
dd if=/dev/block/by-name/super of=/sdcard/super.img
Code:
exit
Code:
exit
Code:
adb pull /sdcard/super.img


  • Extract super.img with lpunpack

Usage on PC(linux):
Code:
./lpunpack - command-line tool for extracting partition images from super

Usage:
  ./lpunpack [options...] SUPER_IMAGE [OUTPUT_DIR]

Options:
  -p, --partition=NAME     Extract the named partition. This can
                           be specified multiple times.
  -S, --slot=NUM           Slot number (default is 0).

**Make sure <output_directory> already exists as this tool will not create a directory for you and will error if not found.**
**If you run this command with no slot specified, it will output 0 byte empty b images.


To extract all A images:
Code:
./lpunpack --slot=0 <path-to-super.img> <output_dir>

To extract all B images:
Code:
./lpunpack --slot=1 <path-to-super.img> <output_dir>



This program can take a couple minutes to run. After it is complete, your $output_dir will contain vendor, system, product and odm with either _a or _b.
Thanks for reading!


:cowboy:ALL CREDIT GOES TO HANETZER @ntzrmtthihu777 FOR ALL OF THIS INFORMATION :cowboy:
He taught me, I just wrote this!​
 
Last edited:

ntzrmtthihu777

Senior Member
May 17, 2015
126
73
Bit of a clarification. If you call lpunpack without any flags, it will extract
{odm,product,system,vendor}_a.img properly without issue, but will create 'empty'
0 byte images for {odm,product,system,vendor}_b.img. In order to get the b-sides,
you must call it again like so:
Code:
./lpunpack --slot=1 super.img
@bynarie
 

elliwigy

Forum Moderator / Recognized Dev / Dev Relations
Staff member
XDA App Taskforce
I did not understand: this tool can extract .img partition or only extract them from phone?

Example: I want to extract product.img partition to edit it and then reconvert to .img and then flash it to phone. Is this possible?

you need to convert it using simg2img then mount the img to edit it then when done use img2simg to convert back into android sparse img then can b flashed
 
  • Like
Reactions: Hitman478™

VladSector

Member
Dec 14, 2014
14
0
Invalid sparse file format at header magic, how to fix this?

Code:
./lpmake --metadata-size 65536 --super-name super --metadata-slots 2 --device super:4294967296 --group main:2647101440 --partition system:readonly:1962512384:main --image system=./system.img --partition vendor:readonly:680239104:main --image vendor=./vendor.img --partition odm:readonly:4349952:main --image odm=./odm.img --sparse --output ./super.img
lpmake I 08-24 00:29:52   598   598 builder.cpp:1012] [liblp]Partition system will resize from 0 bytes to 1962512384 bytes
lpmake I 08-24 00:29:52   598   598 builder.cpp:1012] [liblp]Partition vendor will resize from 0 bytes to 680239104 bytes
lpmake I 08-24 00:29:52   598   598 builder.cpp:1012] [liblp]Partition odm will resize from 0 bytes to 4349952 bytes
Invalid sparse file format at header magic
Invalid sparse file format at header magic
 

Hitman478™

Senior Member
Invalid sparse file format at header magic, how to fix this?

Code:
./lpmake --metadata-size 65536 --super-name super --metadata-slots 2 --device super:4294967296 --group main:2647101440 --partition system:readonly:1962512384:main --image system=./system.img --partition vendor:readonly:680239104:main --image vendor=./vendor.img --partition odm:readonly:4349952:main --image odm=./odm.img --sparse --output ./super.img
lpmake I 08-24 00:29:52   598   598 builder.cpp:1012] [liblp]Partition system will resize from 0 bytes to 1962512384 bytes
lpmake I 08-24 00:29:52   598   598 builder.cpp:1012] [liblp]Partition vendor will resize from 0 bytes to 680239104 bytes
lpmake I 08-24 00:29:52   598   598 builder.cpp:1012] [liblp]Partition odm will resize from 0 bytes to 4349952 bytes
Invalid sparse file format at header magic
Invalid sparse file format at header magic

It is not an error ;)
 

M.sapry

Member
Sep 13, 2016
10
0
Invalid sparse file format at header magic, how to fix this?

Code:
./lpmake --metadata-size 65536 --super-name super --metadata-slots 2 --device super:4294967296 --group main:2647101440 --partition system:readonly:1962512384:main --image system=./system.img --partition vendor:readonly:680239104:main --image vendor=./vendor.img --partition odm:readonly:4349952:main --image odm=./odm.img --sparse --output ./super.img
lpmake I 08-24 00:29:52   598   598 builder.cpp:1012] [liblp]Partition system will resize from 0 bytes to 1962512384 bytes
lpmake I 08-24 00:29:52   598   598 builder.cpp:1012] [liblp]Partition vendor will resize from 0 bytes to 680239104 bytes
lpmake I 08-24 00:29:52   598   598 builder.cpp:1012] [liblp]Partition odm will resize from 0 bytes to 4349952 bytes
Invalid sparse file format at header magic
Invalid sparse file format at header magic

can you upload lpmake ! i cant find it anywhere
 

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    Please see this URL https://android.googlesource.com/platform/build.git/+/eec4a7cba4face3370acb6293ab357879920b467 and this for more information.

    Hi everyone. I'm surprised I havent seen a thread about ota tools yet and lpunpack. This zip file contains a lot of useful tools for modifying super.img and making super.img as well as other tools found in other toolkits. This was just compiled using aosp master. The most useful function is the lpunpack tool which can extract a super.img into system, vendor, odm and product images.


    Browse individual files

    Download HERE
    • Extract super.img from device

    Code:
    adb shell
    Code:
    su
    Code:
    dd if=/dev/block/by-name/super of=/sdcard/super.img
    Code:
    exit
    Code:
    exit
    Code:
    adb pull /sdcard/super.img


    • Extract super.img with lpunpack

    Usage on PC(linux):
    Code:
    ./lpunpack - command-line tool for extracting partition images from super
    
    Usage:
      ./lpunpack [options...] SUPER_IMAGE [OUTPUT_DIR]
    
    Options:
      -p, --partition=NAME     Extract the named partition. This can
                               be specified multiple times.
      -S, --slot=NUM           Slot number (default is 0).

    **Make sure <output_directory> already exists as this tool will not create a directory for you and will error if not found.**
    **If you run this command with no slot specified, it will output 0 byte empty b images.


    To extract all A images:
    Code:
    ./lpunpack --slot=0 <path-to-super.img> <output_dir>

    To extract all B images:
    Code:
    ./lpunpack --slot=1 <path-to-super.img> <output_dir>



    This program can take a couple minutes to run. After it is complete, your $output_dir will contain vendor, system, product and odm with either _a or _b.
    Thanks for reading!


    :cowboy:ALL CREDIT GOES TO HANETZER @ntzrmtthihu777 FOR ALL OF THIS INFORMATION :cowboy:
    He taught me, I just wrote this!​
    2
    build an arm version of lpunpack ?
    For android?
    You can take the build tree from my github (I cannot post external links due to the small number of posts).
    2
    Hello,

    After unpacking the super image I get successfully the contained images, but I'm having a problem at the moment of mounting them:

    The ony way I could make it work is as follows (but of course I don't have write access):
    Code:
    sudo mount -o ro system_a.img ./mount
    Also I cannot modify any of the permissions once mounted.

    I didn't have this issue modifying Android Images previous to the dynamic partition implementation. Someone had experience this issue?
    You need to deduplicate the blocks first. Which you can do by running e2fsck -E unshare_blocks, but first you need to resize the partition to give enough space.

    If anyone's wondering, here's how you can directly modify logical partition and flash it back to your device.


    Big thanks to @thohac for pretty much telling me how to do it and getting me in the right track.
    1
    I did not understand: this tool can extract .img partition or only extract them from phone?

    Example: I want to extract product.img partition to edit it and then reconvert to .img and then flash it to phone. Is this possible?

    you need to convert it using simg2img then mount the img to edit it then when done use img2simg to convert back into android sparse img then can b flashed
    1
    can't get it to work... it always says "bash: ./lpunpack: Permission denied"

    can someone help?

    trying to run it in mint4kitchen with all updates
    Probably need to chmod it..
    Code:
    chmod +x lpunpack
    OR
    Code:
    chmod 755 lpunpack