[LINUX][GUIDE] ROM Payload Image Dump

Search This thread

Agimax

Senior Member
Nov 17, 2009
1,250
1,314
Indianapolis
OnePlus 8 Pro
ROM PAYLOAD IMAGE DUMPER GUIDE - LINUX EDITION

From Full OTA ROMs

For those that don't have a windows machine for dumping the Image Files from the FULL ROM payload.bin files, this tutorial will show you how to do it on most Linux machines using a Ubuntu based OS.

*This method does not yet work on incremental updates -use Full ROMs Only!

1) Right-Click on each link below and 'Save-As' to the same directory as the 'ROM.ZIP' file you want extracted

https://raw.githubusercontent.com/cyxx/extract_android_ota_payload/master/extract_android_ota_payload.py<---All Credit Goes To Gregory cyxx from GitHub
https://raw.githubusercontent.com/cyxx/extract_android_ota_payload/master/update_metadata_pb2.py<---All Credit Goes To Gregory cyxx from GitHub

2) Open a Linux terminal session and install the 2 required files with the commands below:
Code:
sudo apt-get install python
sudo apt-get install python-protobuf
3) Change the terminal directory to the same directory as your 'ROM.zip' file that also contains your python files and enter the command:

COMMAND FORMAT: sudo python extract_android_ota_payload.py ROM.zip OUTPUTDIRECTORY

EXAMPLE:
Code:
sudo python extract_android_ota_payload.py OnePlus8ProOxygen_15.X.13_OTA_0130_all_2010200209_ 597442495fcc435a.zip /home/administrator/Downloads/

If successful, you will see the payload.bin extracted from the ZIP file and all ROM Images created right after in the output directory chosen.

Output Example:
Code:
administrator@Main:~/Downloads$ sudo python extract_android_ota_payload.py OnePlus8ProOxygen_15.X.13_OTA_0130_all_2010200209_ 597442495fcc435a.zip /home/administrator/Downloads/
Extracting 'payload.bin' from OTA file...
Extracting 'abl.img'
Extracting 'boot.img'
Extracting 'dtbo.img'
Extracting 'logo.img'
Extracting 'odm.img'
Extracting 'product.img'
Extracting 'recovery.img'
Extracting 'system.img'
Extracting 'system_ext.img'
Extracting 'vbmeta.img'
Extracting 'vbmeta_system.img'
Extracting 'vendor.img'
Extracting 'aop.img'
Extracting 'bluetooth.img'
Extracting 'cmnlib64.img'
Extracting 'cmnlib.img'
Extracting 'devcfg.img'
Extracting 'dsp.img'
Extracting 'featenabler.img'
Extracting 'hyp.img'
Extracting 'imagefv.img'
Extracting 'keymaster.img'
Extracting 'modem.img'
Extracting 'multiimgoem.img'
Extracting 'qupfw.img'
Extracting 'storsec.img'
Extracting 'tz.img'
Extracting 'uefisecapp.img'
Extracting 'xbl_config.img'
Extracting 'xbl.img'
Extracting 'mdm_oem_stanvbk.img'
Extracting 'spunvm.img'

You now have the boot.img for creating a rooted boot.img using Magisk or you need to re-flash any of the factory partitions from Fasboot mode :)

./
 
Last edited:

kevp75

Recognized Contributor
Aug 29, 2012
8,692
7,455
MA
kevinpirnie.com
Google Pixel 6 Pro
OnePlus 11
Error in Ubuntu 20.04

Code:
Traceback (most recent call last):
  File "extract_android_ota_payload.py", line 13, in <module>
    import update_metadata_pb2
  File "/mnt/d/Downloads/Phone/update_metadata_pb2.py", line 7, in <module>
    from google.protobuf import descriptor as _descriptor
ModuleNotFoundError: No module named 'google'
 

kevp75

Recognized Contributor
Aug 29, 2012
8,692
7,455
MA
kevinpirnie.com
Google Pixel 6 Pro
OnePlus 11
Error in Ubuntu 20.04

Code:
Traceback (most recent call last):
  File "extract_android_ota_payload.py", line 13, in <module>
    import update_metadata_pb2
  File "/mnt/d/Downloads/Phone/update_metadata_pb2.py", line 7, in <module>
    from google.protobuf import descriptor as _descriptor
ModuleNotFoundError: No module named 'google'

To fix this issue on Ubuntu 20.04, run the following
Code:
sudo pip3 install --upgrade protobuf
 
Dispenses a lot of gibberish.

Code:
russell@russell-Lenovo-B570:/media/russell/Windows/Users/Russell/Downloads/Android/Pixel$ sudo python extract_android_ota_payload.py lineage-17.1-20210327-nightly-bonito-signed.zip /media/russell/Windows/Users/Russell/Downloads/Android/Pixel
Traceback (most recent call last):
  File "extract_android_ota_payload.py", line 13, in <module>
    import update_metadata_pb2
  File "/media/russell/Windows/Users/Russell/Downloads/Android/Pixel/update_metadata_pb2.py", line 23, in <module>
    rminor_version\x18\x0c \x01(\r:\x01\x30\x12;\n\npartitions\x18\r \x03(\x0b\x32\'.chromeos_update_engine.PartitionUpdate\x12\x15\n\rmax_timestamp\x18\x0e \x01(\x03\x12T\n\x1a\x64ynamic_partition_metadata\x18\x0f \x01(\x0b\x32\x30.chromeos_update_engine.DynamicPartitionMetadataB\x02H\x03')
TypeError: __new__() got an unexpected keyword argument 'serialized_options'

But this tutorial worked:
 
Last edited:

Anvil101

New member
Feb 26, 2022
2
0
Hello,
I get this error when trying to process the extraction:

~/Desktop$ sudo python extract_android_ota_payload.py OnePlus8TOxygen_15.O.30_OTA_0300_all_2112211344_d865f7d8ac014f65 /home/Desktop/OnePlus8T
Traceback (most recent call last):
File "extract_android_ota_payload.py", line 144, in <module>
main(filename, output_dir)
File "extract_android_ota_payload.py", line 112, in main
payload_file = open(filename, 'rb')
IOError: [Errno 21] Is a directory: 'OnePlus8TOxygen_15.O.30_OTA_0300_all_2112211344_d865f7d8ac014f65'

Any help would be appreciated.


BIG EDIT: I'm an idiot. I didn't declare .zip at the end of the file name because I also have a directory the exact same name as the file. It worked.
 
Last edited:

Markpeng0315

Member
May 9, 2019
33
7
hey bro, it do extract .img files , and works with hydragon11/oxygen11 , but when I tried to do so on android 12 ( Oxygen OS12 for global, and color os for china mainland models ) , it ( the system.img ) was neither raw nor spilit. but seems a apex_payload.img. I could not extract ant files as my zip tool tell me it's crc error. what u recommened me do next step.
 

Markpeng0315

Member
May 9, 2019
33
7
hey bro, it do extract .img files , and works with hydragon11/oxygen11 , but when I tried to do so on android 12 ( Oxygen OS12 for global, and color os for china mainland models ) , it ( the system.img ) was neither raw nor spilit. but seems a apex_payload.img. I could not extract ant files as my zip tool tell me it's crc error. what u recommened me do next step.
on hydragon os fourm, i built the apex extract tool,you needn‘t build full aosp now.
 
D

Deleted member 12096491

Guest
I spent 4 hrs losing brain cells trying to find out how to extract the boot.img from the phone without twrp to no avail. This was a lifesaver thank you.
 
  • Like
Reactions: flash713

kellrobinson

Member
Oct 23, 2012
29
6
Hello, thanks for this tool. I am getting this error and I could use some help understanding it.
a@galliumos:~/Desktop/pixper$ sudo python extract_android_ota_payload.py PixelExperience_bonito-12.1-20220414-1502-OFFICIAL.zip . [sudo] password for a: Traceback (most recent call last): File "extract_android_ota_payload.py", line 13, in <module> import update_metadata_pb2 File "/home/a/Desktop/pixper/update_metadata_pb2.py", line 23, in <module> rminor_version\x18\x0c \x01(\r:\x01\x30\x12;\n\npartitions\x18\r \x03(\x0b\x32\'.chromeos_update_engine.PartitionUpdate\x12\x15\n\rmax_timestamp\x18\x0e \x01(\x03\x12T\n\x1a\x64ynamic_partition_metadata\x18\x0f \x01(\x0b\x32\x30.chromeos_update_engine.DynamicPartitionMetadataB\x02H\x03') TypeError: __new__() got an unexpected keyword argument 'serialized_options' a@galliumos:~/Desktop/pixper$
Here is the contents of the folder
pixper.png
 
Mar 16, 2014
24
3
Florida
LG V60 ThinQ
Get following error:
sudo python extract_android_ota_payload.py OnePlusN10Oxygen_14.E30_OTA_0300_all_2106231157_09dc03f.zip
File "extract_android_ota_payload.py", line 1689
e: update_metadata.proto
^
SyntaxError: invalid syntax
 

sbpetrack

Member
Mar 14, 2012
43
8
Tel Aviv-Yafo
I spent a few hours battling various python errors, some of which appeared in previous posts in this thread, and some of which didn't. The following generic fact/advice might help others with similar problems:

As (perhaps essential, perhaps irrelevant) background, I note that I don't really know python, and that I'm using arch linux. Note: arch linux natively uses pacman and not apt-get etc to install/uninstall/manage packages.

The root cause of the various "import" and "name" and "unknown location" and other python errors seems to me to be the following:

1. There might be some conflict between what happens when you install/uninstall/manage python modules using pacman vs. pip. To be specific, I don't know if a command such as

sudo pip install protobuf

does the same thing as

sudo pacman -S python-protobuf

2. In the end, python seems to me to be very bad at synchronizing different versions of different modules. In the end, what WORKED -- that is, what caused me to get ZERO errors and to extract all the .bin files as advertised, was that i made CERTAIN that protobuf was UNINSTALLED:

sudo pacman -R python-protobuf
sudo pip uninstall protobuf

(note, in my case, the pacman command sort of failed, because of the myriad dependencies on protobuf, but the pip command succeeded, because it gave me the choice to remove ALL dependencies).

And then I had to be certain to install an OLD version of protobuf:

sudo pip install protobuf==3.6

Once I did this, the commands at the start of this thread worked perfectly.
 

bartito

Inactive Recognized Developer
Dec 1, 2005
3,962
1,800
I want to replace an APK from the ROM I use and I want to unpack the payload.bin (done), mount the product partition (done), replace the APK (done) then repack the payload.bin with the updated image/s.
It's possible to do it?
Thanks
 

norwood7

Member
Oct 16, 2019
8
1
Dispenses a lot of gibberish.

Code:
russell@russell-Lenovo-B570:/media/russell/Windows/Users/Russell/Downloads/Android/Pixel$ sudo python extract_android_ota_payload.py lineage-17.1-20210327-nightly-bonito-signed.zip /media/russell/Windows/Users/Russell/Downloads/Android/Pixel
Traceback (most recent call last):
  File "extract_android_ota_payload.py", line 13, in <module>
    import update_metadata_pb2
  File "/media/russell/Windows/Users/Russell/Downloads/Android/Pixel/update_metadata_pb2.py", line 23, in <module>
    rminor_version\x18\x0c \x01(\r:\x01\x30\x12;\n\npartitions\x18\r \x03(\x0b\x32\'.chromeos_update_engine.PartitionUpdate\x12\x15\n\rmax_timestamp\x18\x0e \x01(\x03\x12T\n\x1a\x64ynamic_partition_metadata\x18\x0f \x01(\x0b\x32\x30.chromeos_update_engine.DynamicPartitionMetadataB\x02H\x03')
TypeError: __new__() got an unexpected keyword argument 'serialized_options'

But this tutorial worked:

Old thread I know, but just wanted to record what finally worked for me:

my system had 'python' and 'python3'. Replacing 'python' with 'python3' in the original command-line entry fixed everything.
 
  • Like
Reactions: xBkKx

Spaceboy60

Senior Member
Dec 22, 2014
868
105
Xiaomi Poco X5 Pro
sudo python extract_android_ota_payload.py payload.bin /home/Spaceboy/Downloads/Custom Roms/output


Traceback (most recent call last):
File "/home/Spaceboy/Downloads/Custom Roms/extract_android_ota_payload.py", line 13, in <module>
import update_metadata_pb2
File "/home/Spaceboy/Downloads/Custom Roms/update_metadata_pb2.py", line 34, in <module>
_descriptor.EnumValueDescriptor(
File "/usr/local/lib64/python3.11/site-packages/google/protobuf/descriptor.py", line 755, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

Running fedora 38
 

Top Liked Posts

  • There are no posts matching your filters.
  • 17
    ROM PAYLOAD IMAGE DUMPER GUIDE - LINUX EDITION

    From Full OTA ROMs

    For those that don't have a windows machine for dumping the Image Files from the FULL ROM payload.bin files, this tutorial will show you how to do it on most Linux machines using a Ubuntu based OS.

    *This method does not yet work on incremental updates -use Full ROMs Only!

    1) Right-Click on each link below and 'Save-As' to the same directory as the 'ROM.ZIP' file you want extracted

    https://raw.githubusercontent.com/cyxx/extract_android_ota_payload/master/extract_android_ota_payload.py<---All Credit Goes To Gregory cyxx from GitHub
    https://raw.githubusercontent.com/cyxx/extract_android_ota_payload/master/update_metadata_pb2.py<---All Credit Goes To Gregory cyxx from GitHub

    2) Open a Linux terminal session and install the 2 required files with the commands below:
    Code:
    sudo apt-get install python
    sudo apt-get install python-protobuf
    3) Change the terminal directory to the same directory as your 'ROM.zip' file that also contains your python files and enter the command:

    COMMAND FORMAT: sudo python extract_android_ota_payload.py ROM.zip OUTPUTDIRECTORY

    EXAMPLE:
    Code:
    sudo python extract_android_ota_payload.py OnePlus8ProOxygen_15.X.13_OTA_0130_all_2010200209_ 597442495fcc435a.zip /home/administrator/Downloads/

    If successful, you will see the payload.bin extracted from the ZIP file and all ROM Images created right after in the output directory chosen.

    Output Example:
    Code:
    administrator@Main:~/Downloads$ sudo python extract_android_ota_payload.py OnePlus8ProOxygen_15.X.13_OTA_0130_all_2010200209_ 597442495fcc435a.zip /home/administrator/Downloads/
    Extracting 'payload.bin' from OTA file...
    Extracting 'abl.img'
    Extracting 'boot.img'
    Extracting 'dtbo.img'
    Extracting 'logo.img'
    Extracting 'odm.img'
    Extracting 'product.img'
    Extracting 'recovery.img'
    Extracting 'system.img'
    Extracting 'system_ext.img'
    Extracting 'vbmeta.img'
    Extracting 'vbmeta_system.img'
    Extracting 'vendor.img'
    Extracting 'aop.img'
    Extracting 'bluetooth.img'
    Extracting 'cmnlib64.img'
    Extracting 'cmnlib.img'
    Extracting 'devcfg.img'
    Extracting 'dsp.img'
    Extracting 'featenabler.img'
    Extracting 'hyp.img'
    Extracting 'imagefv.img'
    Extracting 'keymaster.img'
    Extracting 'modem.img'
    Extracting 'multiimgoem.img'
    Extracting 'qupfw.img'
    Extracting 'storsec.img'
    Extracting 'tz.img'
    Extracting 'uefisecapp.img'
    Extracting 'xbl_config.img'
    Extracting 'xbl.img'
    Extracting 'mdm_oem_stanvbk.img'
    Extracting 'spunvm.img'

    You now have the boot.img for creating a rooted boot.img using Magisk or you need to re-flash any of the factory partitions from Fasboot mode :)

    ./
    2
    Error in Ubuntu 20.04

    Code:
    Traceback (most recent call last):
      File "extract_android_ota_payload.py", line 13, in <module>
        import update_metadata_pb2
      File "/mnt/d/Downloads/Phone/update_metadata_pb2.py", line 7, in <module>
        from google.protobuf import descriptor as _descriptor
    ModuleNotFoundError: No module named 'google'

    To fix this issue on Ubuntu 20.04, run the following
    Code:
    sudo pip3 install --upgrade protobuf
    1
    D
    Deleted member 12096491
    I spent 4 hrs losing brain cells trying to find out how to extract the boot.img from the phone without twrp to no avail. This was a lifesaver thank you.
    1
    Dispenses a lot of gibberish.

    Code:
    russell@russell-Lenovo-B570:/media/russell/Windows/Users/Russell/Downloads/Android/Pixel$ sudo python extract_android_ota_payload.py lineage-17.1-20210327-nightly-bonito-signed.zip /media/russell/Windows/Users/Russell/Downloads/Android/Pixel
    Traceback (most recent call last):
      File "extract_android_ota_payload.py", line 13, in <module>
        import update_metadata_pb2
      File "/media/russell/Windows/Users/Russell/Downloads/Android/Pixel/update_metadata_pb2.py", line 23, in <module>
        rminor_version\x18\x0c \x01(\r:\x01\x30\x12;\n\npartitions\x18\r \x03(\x0b\x32\'.chromeos_update_engine.PartitionUpdate\x12\x15\n\rmax_timestamp\x18\x0e \x01(\x03\x12T\n\x1a\x64ynamic_partition_metadata\x18\x0f \x01(\x0b\x32\x30.chromeos_update_engine.DynamicPartitionMetadataB\x02H\x03')
    TypeError: __new__() got an unexpected keyword argument 'serialized_options'

    But this tutorial worked:

    Old thread I know, but just wanted to record what finally worked for me:

    my system had 'python' and 'python3'. Replacing 'python' with 'python3' in the original command-line entry fixed everything.