[TOOL][WIN,LIN,AND,DARW] Super image tools | extract or make partitions RW in super partition

Search This thread

PTechz

Member
Jun 25, 2022
13
5
Please help me, I got these 3 files.

1. system.ext4
2. product.ext4
3. vendor.ext4

I used this tool in Linux. Now, what to do with these three files. Please help me.
 

Attachments

  • Screenshot from 2022-07-02 15-54-30.png
    Screenshot from 2022-07-02 15-54-30.png
    5.8 KB · Views: 15
  • Haha
Reactions: aIecxs

munjeni

Senior Member
Jun 2, 2011
9,581
22,215
Better question, whats your plan? You can use them for example to extract some library, some apps... etc. You can mount them now like this:

mkdir rr
mount -t ext4 -o,ro system.ext4 rr
 
  • Like
Reactions: PTechz

PTechz

Member
Jun 25, 2022
13
5
Better question, whats your plan? You can use them for example to extract some library, some apps... etc. You can mount them now like this:

mkdir rr
mount -t ext4 -o,ro system.ext4 rr
---------------------
Bro, how can I convert these three files into one (super.bin) file. I want to flash this file via fastboot. Please help me.

Yeah, I edited these files, removed some apps. But, don't know how to convert these three files into one (super.bin) file. Please help me, have a good day bro.

:)
 

munjeni

Senior Member
Jun 2, 2011
9,581
22,215
---------------------
Bro, how can I convert these three files into one (super.bin) file. I want to flash this file via fastboot. Please help me.

Yeah, I edited these files, removed some apps. But, don't know how to convert these three files into one (super.bin) file. Please help me, have a good day bro.

:)
Take a look here https://forum.xda-developers.com/t/...-superrw-featuring-makerw-read-write.4247311/ , those script doing the same but also convert it back to super image
 
  • Haha
Reactions: lebigmac

munjeni

Senior Member
Jun 2, 2011
9,581
22,215
Also read post 376 if you have modified those partitions you have definitelly removed ton of files referenced to that what you have deleted!
 
  • Like
Reactions: PTechz

munjeni

Senior Member
Jun 2, 2011
9,581
22,215
https://github.com/munjeni/super_image_dumper/blob/master/superrepack.cpp#L276

But what should I use instead the %s (losetup --offset=%s --sizelimit=%s %s %s) ?
You no need losetup, that tool is used for mount partitions on the fly without extracting them. In your case you have partitions extracted allready, so skip losetup and try the rest of commands. And sorry I do not have free time for this, further questions I will probably ignore sorry. Thats a very easy and basic tool and everybody who have at least basic linux skills and C skills is able to understand whats going on, I can't help and don't have free time for this thread, in short explanation:

You got output for example like this:
Code:
  partition_1_name = system_a
    attributes = 0x1
    first_extent_index = 0x0
    num_extents = 0x1
    group_index = 0x1
    partition_group = somc_dynamic_partitions_a
    extent num_sectors = 0x336390 (0x66c72000 bytes total)
    extent target_type = 0x0
    extent target_data = 0x800 (dumping offset = 0x100000)
    extent target_source = 0x0
      Filetype EXT4. EXT4 size = 0x6526c000
      Dumping system_a.ext4 ...

To convert this to losetup %s would be:
extent target_data x 512 = 0x800 x 512 = 0x100000
extent num_sectors x 512 = 0x336390 x 512 = 0x66c72000
Code:
losetup --offset=0x100000 --sizelimit=0x66c72000 super.img /dev/loop0
mkdir system_a
mount /dev/loop0 system_a
.... etc... etc

Free space = 0x66c72000 - 0x6526c000 = 0x1A06000
Resize your partition to 0x66c72000 because e2fsck unshare blocks feature reguire increased partition size because clone blocks is performed while unsharing blocks. Unsharing blocks is reguired to convert from dynamic partition to normal partition. so some extra free space is needed for that, but not to exceed maximum partition size in our case extent num_sectors x 512 . In short this is explanation how my tool work. My choice for using losetup is because I no need to extract partition, instead I have virtualy mounted every each partition on the fly trought offset and size calculation, in that case we know where is start and end of the every each partition. For further understanding how I have done all that things on the fly take a look at source code of my tool to understand it better, there is everything you need to know! Hope this help!
 
Last edited:

Pervokur

Senior Member
Feb 15, 2022
146
44
You no need losetup, that tool is used for mount partitions on the fly without extracting them. In your case you have partitions extracted allready, so skip losetup and try the rest of commands. And sorry I do not have free time for this, further questions I will probably ignore sorry. Thats a very easy and basic tool and everybody who have at least basic linux skills and C skills is able to understand whats going on, I can't help and don't have free time for this thread, in short explanation:

You got output for example like this:
Code:
  partition_1_name = system_a
    attributes = 0x1
    first_extent_index = 0x0
    num_extents = 0x1
    group_index = 0x1
    partition_group = somc_dynamic_partitions_a
    extent num_sectors = 0x336390 (0x66c72000 bytes total)
    extent target_type = 0x0
    extent target_data = 0x800 (dumping offset = 0x100000)
    extent target_source = 0x0
      Filetype EXT4. EXT4 size = 0x6526c000
      Dumping system_a.ext4 ...

To convert this to losetup %s would be:
extent target_data x 512 = 0x800 x 512 = 0x100000
extent num_sectors x 512 = 0x336390 x 512 = 0x66c72000
Code:
losetup --offset=0x100000 --sizelimit=0x66c72000 super.img /dev/loop0
mkdir system_a
mount /dev/loop0 system_a
.... etc... etc

Free space = 0x66c72000 - 0x6526c000 = 0x1A06000
Resize your partition to 0x66c72000 because e2fsck unshare blocks feature reguire increased partition size because clone blocks is performed while unsharing blocks. Unsharing blocks is reguired to convert from dynamic partition to normal partition. so some extra free space is needed for that, but not to exceed maximum partition size in our case extent num_sectors x 512 . In short this is explanation how my tool work. My choice for using losetup is because I no need to extract partition, instead I have virtualy mounted every each partition on the fly trought offset and size calculation, in that case we know where is start and end of the every each partition. For further understanding how I have done all that things on the fly take a look at source code of my tool to understand it better, there is everything you need to know! Hope this help!
Thx for losetup! My recovery can't mount logical partitions (/system, /vendor etc).
But this method works from recovery.

lpdump:

Super partition layout:
------------------------
super: 2048 .. 4712448: system (4710400 sectors)
super: 5072896 .. 7376656: vendor (2303760 sectors)
super: 7376896 .. 7389008: oem (12112 sectors)
super: 7389184 .. 7389864: vgc (680 sectors)

offset = first number in string * 512
2048 * 512 = 1048576

sizelimit = size in sectors * 512
4710400 * 512 = 2411724800
----------
mkdir mysystem
setenforce 0
/data/local/tmp/losetup --offset=1048576 --sizelimit=2411724800 /dev/block/loop0 /dev/block/by-name/super
mount -t ext4 /dev/block/loop0 mysystem
 
Last edited:
  • Like
Reactions: munjeni

munjeni

Senior Member
Jun 2, 2011
9,581
22,215
Yes thats it! Notice that how losetup is an powerfull tool! Android losetup do not have those two parameters and who have plan to use losetup must compile an true linux losetup from source code. I have booth precompiled https://github.com/munjeni/super_image_dumper/tree/master/include . When I decide t buy next phone it will be probably inevitably with included dynamic partition table, and I will than definitelly complete our tool to fully working one click solution. E2fsck need to be modified to get it work with low free space, that will prevent partition repair coruption because of lack of free space for clone block while unsharing blocks, and that's all that needs to be applied to make this tool work properly! If someone already had an idea how to do this, I would be happy to implement it in my tool!

Edit:
This need to be tried https://patchwork.ozlabs.org/project/linux-ext4/patch/20190614114530.5663-1-dongyan[email protected]/
Some discusion https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=956509 , https://www.mail-archive.com/[email protected]/msg2333701.html
 

Attachments

  • unshare_blocks.jpg
    unshare_blocks.jpg
    78.6 KB · Views: 7
Last edited:
  • Love
Reactions: HemanthJabalpuri

munjeni

Senior Member
Jun 2, 2011
9,581
22,215
I'm applied patch above and it seems no files is deleted! :)

/media/hdd/sony/rom/e2fsck/sbin/e2fsck -y -E unshare_blocks -E clone=zero -E shared=preserve ./system_a.ext4

Even it worked without resizing partition :)

Edit:
I will try compare files before unshare blocks and after unshare blocks, using git tool and let you know.
 
Last edited:

munjeni

Senior Member
Jun 2, 2011
9,581
22,215
It seems one file is missing. Before unsharing blocks there was 7370 things inside ext4 image, after unsharing blocks one file is missing as you can see count is now 7369 :( So with this patch for e2fsck we stll have the same problem! :(

Code:
[email protected] /media/hdd/sony/rom # /media/hdd/sony/rom/e2fsck/sbin/e2fsck -y -E unshare_blocks -E clone=zero -E shared=preserve ./system_a.ext4
e2fsck 1.46.5 (30-Dec-2021)
/: clean, 6470/6720 files, 478069/487572 blocks
[email protected] /media/hdd/sony/rom # mount -t ext4 -o,rw system_a.ext4 rr
[email protected] /media/hdd/sony/rom # ls -R1A rr | wc -l
7369
[email protected] /media/hdd/sony/rom # 7370
bash: 7370: command not found

You should try compare what is deleted! It looks like com.android.vndk.current.apex is deleted?!! If we figure out why it is deleted than probably we have fix for our problem! :)

indeed deleted!
Code:
[email protected] /media/hdd/sony/rom # ls rr/system/apex/com.android.vndk.current.apex
ls: cannot access 'rr/system/apex/com.android.vndk.current.apex': No such file or directory

That's why android runs into a boot loop! Maybe things can be fixed by implementing something which will make symlinks instead of clonning, in the same time it might save a lot of free space, in the same time it will break selinux labels! So in general the better way is try fix problem related to deletion. Good luck developers!!! :D
 

Attachments

  • list_of_files.rar
    59.9 KB · Views: 1
  • e2fsck.log
    8.1 MB · Views: 3
Last edited:

Pervokur

Senior Member
Feb 15, 2022
146
44
Yes thats it! Notice that how losetup is an powerfull tool! Android losetup do not have those two parameters and who have plan to use losetup must compile an true linux losetup from source code. I have booth precompiled https://github.com/munjeni/super_image_dumper/tree/master/include . When I decide t buy next phone it will be probably inevitably with included dynamic partition table, and I will than definitelly complete our tool to fully working one click solution. E2fsck need to be modified to get it work with low free space, that will prevent partition repair coruption because of lack of free space for clone block while unsharing blocks, and that's all that needs to be applied to make this tool work properly! If someone already had an idea how to do this, I would be happy to implement it in my tool!

Edit:
This need to be tried https://patchwork.ozlabs.org/project/linux-ext4/patch/[email protected]/
Some discusion https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=956509 , https://www.mail-archive.com/[email protected]/msg2333701.html
actually there is very simple way to do things with super partition - run Ubuntu from termux as root

no need to compile losetup ><

am I not genius? lol
You can even use gui with vnc/xsdl
 

Attachments

  • IMG_20220704_004107.jpg
    IMG_20220704_004107.jpg
    164.7 KB · Views: 16
  • Screenshot_20220704-012344_Termux.png
    Screenshot_20220704-012344_Termux.png
    221.5 KB · Views: 13
Last edited:

munjeni

Senior Member
Jun 2, 2011
9,581
22,215
Ubuntu, windows, dos...etc emulators inside android is nothing new, these apps exist for almost ten years, and since Ubuntu is real Linux distro its expected that native tools like losetup or e2fsprogs is allready precompiled and working. Problem with superrepack is that its not possible to unshare blocks because partition size is not enought for that, even can't be resized to the enought size in order to unshare_blocks trought e2fsck
 
Last edited:

starbucks2010

Senior Member
Jun 30, 2010
3,156
1,870
You no need losetup, that tool is used for mount partitions on the fly without extracting them. In your case you have partitions extracted allready, so skip losetup and try the rest of commands. And sorry I do not have free time for this, further questions I will probably ignore sorry. Thats a very easy and basic tool and everybody who have at least basic linux skills and C skills is able to understand whats going on, I can't help and don't have free time for this thread, in short explanation:

You got output for example like this:
Code:
  partition_1_name = system_a
    attributes = 0x1
    first_extent_index = 0x0
    num_extents = 0x1
    group_index = 0x1
    partition_group = somc_dynamic_partitions_a
    extent num_sectors = 0x336390 (0x66c72000 bytes total)
    extent target_type = 0x0
    extent target_data = 0x800 (dumping offset = 0x100000)
    extent target_source = 0x0
      Filetype EXT4. EXT4 size = 0x6526c000
      Dumping system_a.ext4 ...

To convert this to losetup %s would be:
extent target_data x 512 = 0x800 x 512 = 0x100000
extent num_sectors x 512 = 0x336390 x 512 = 0x66c72000
Code:
losetup --offset=0x100000 --sizelimit=0x66c72000 super.img /dev/loop0
mkdir system_a
mount /dev/loop0 system_a
.... etc... etc

Free space = 0x66c72000 - 0x6526c000 = 0x1A06000
Resize your partition to 0x66c72000 because e2fsck unshare blocks feature reguire increased partition size because clone blocks is performed while unsharing blocks. Unsharing blocks is reguired to convert from dynamic partition to normal partition. so some extra free space is needed for that, but not to exceed maximum partition size in our case extent num_sectors x 512 . In short this is explanation how my tool work. My choice for using losetup is because I no need to extract partition, instead I have virtualy mounted every each partition on the fly trought offset and size calculation, in that case we know where is start and end of the every each partition. For further understanding how I have done all that things on the fly take a look at source code of my tool to understand it better, there is everything you need to know! Hope this help!
Thank you for the explanation.
I don't know if I missed something or the fact that the vendor.img I use is in f2fs format but I cannot seem to be able to mount the resulted vendor.img (result after running v15 tool).
Is there a specific command to mount f2fs partitions besides -t f2fs options in mount command?

I can mount vendor.img using udisksctl loop-setup -f vendor.img but the mounted image is read-only.

Thanks.
 

Attachments

  • super_error_mount.png
    super_error_mount.png
    68.5 KB · Views: 9
Last edited:

munjeni

Senior Member
Jun 2, 2011
9,581
22,215
Yes I'm getting the same while want to mount ext4, trick is to pass -o,ro parameter to mount:

mount -o,ro xxx xxx
 

munjeni

Senior Member
Jun 2, 2011
9,581
22,215
Thank you for the explanation.
I don't know if I missed something or the fact that the vendor.img I use is in f2fs format but I cannot seem to be able to mount the resulted vendor.img (result after running v15 tool).
Is there a specific command to mount f2fs partitions besides -t f2fs options in mount command?

I can mount vendor.img using udisksctl loop-setup -f vendor.img but the mounted image is read-only.

Thanks.
I see that you have losetup vendor.img, thats wrong, you need to losetup super.img ! Vendor.img you no need losetup, instead directly mount with mount command
 

starbucks2010

Senior Member
Jun 30, 2010
3,156
1,870
But, if I use mount for vendor, I cannor modify anything inside this image as is always mounted read-only.
 

munjeni

Senior Member
Jun 2, 2011
9,581
22,215
But, if I use mount for vendor, I cannor modify anything inside this image as is always mounted read-only.
You even can't modify anything since thats dynamic partition! If you delete one file you will delete a lot off files without knowing that! See how dynamic partition work! Option is to resize partition first than perform unshare blocks, that will convert your dynamic partition to normal, after that you can do whatever you need. Wait a bit I will tell you step by step how to reconstruct whole super image with an example in details!
 
Last edited:
  • Like
Reactions: starbucks2010

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    is it working on any stock firmware ? (like motorola ?) with Android 12 ?

    And, this patch is permanent ? Or if i re-flash the original firmware the partition will be again RO ?

    is it secure ? (if fail can be re-flash and will work all ?) the partitions can be delete or some like that (problems)?

    Thanks
  • 43
    Disclaimer:

    Super image tools was made for testing and educational purposes, ME is not responsible for what you do on/with your device using our tools, you must agree that you using our tools on your own risk, I am not responsible for anything else!


    How to use superunpack:

    - First step, unpack super.sin using my tool or use @IgorEisberg unsin tool
    - Step two, Superunpack. On windows just drag and drop unpacked super image onto our exe to start extraction. Also you can use it from command line, from script or from etc. On Linux use it from command line. No need to set slot like it was a case on lpunpack, our tool will auto extract all slot images for you, enjoy!
    - If you need to unpack partition images in RW mode add parameter 1 at the end of command line e.g. "superunpack super.img 1", than resize partition using resize2fs, repair and unshare blocks using e2fsck. Or if you unpack without rw you no need to resize or repair it, just mount it ro.

    How to manualy patch super partition in under Linux:
    https://forum.xda-developers.com/t/...s-rw-in-super-partition.4120963/post-87112415

    Note that, superunpack is a tool for extract all logical partitions from super image or directly from super partition.

    How to use superrepack:

    adb push superrepack.arm64_pie /data/local/tmp
    adb shell
    su
    cd /data/local/tmp
    mv superrepack.arm64_pie superrepack
    chmod 755 superrepack
    stop
    ./superrepack /dev/block/bootdevice/by-name/super system_a
    sync
    reboot

    Note that, superrepack is a tool to convert logical RO partitions iside your phone super partition to RW mode without extracting anything, all things is done on the fly directly inside super partition/image! In this example system_a partiton is converted to the rw mode, if you need other partitions to rw just change system_a argument. Or if you need all partitions to rw mode do it without partition rw argumet e.g: "./superrepack /dev/block/bootdevice/by-name/super". YOU MUST RUN TOOL 4-5 TIMES UNTIL ALL ERRORS DISAPEARS!!! One of the well known errors is: "Couldn't clone file: Could not allocate block in ext2 filesystem". Look at /data/local/tmp/script.log each time and make sure it not contain any error otherwise you are not done things right and partition is not repaired yet!!! More info -> https://forum.xda-developers.com/t/...s-rw-in-super-partition.4120963/post-84966715

    Platform:

    - Superunpack is working on Windows, Linux, Android, Darwin11, just chose right binary.
    - Superrepack is working only under android


    Changelog:

    - version 1 (21.Jun.2020), initial version
    - version 1.1 (22.Jun.2020), dump file format detection, partition size correction in case ext4, partition group detection, have extraction progress bar, improvements
    - version 2 (03.04.2021) implemented possibility to extract partition images to rw mode using Superunpack & I have made new tool called Superrepack
    - version 2 (04.04.2021) implemented arguments so you would do conversion on single partition instead of doing it on all partitions
    - version 3 (04.04.2021) implemented return codes and implemented output logs to be more scripting friendly
    - version 4 - not released
    - version 5 (08.04.2021) implemented resize and repair partitions after switching to rw mode. Implemented build script for building resize2fs, e2fsck, simg2ims, img2simg, lptools
    - version 6 (08.04.2021) better loop device detection and setup
    - version 7 (08.04.2021) fix selinux status detection
    - version 8 (15.04.2021) fix loop device setup in superrepack
    - version 9 (16.04.2021) make losetup android compatible
    - version 10 - not released
    - version 11 (01.05.2021) simplified, removed needs for parameter rw, implemented dm-verity disabler
    - version 12 (05.05.2021) make old logs always deleted before fresh log is created, this prevent concentation with old logs
    - version 13 (06.05.2021) make linux version so you should do the things on your super partition dump in linux machine
    - version 14 (07.05.2021) fix compilation mess between linux and android
    - version 15 (08.05.2021) use libselinux to determine and set selinux to permissive mode instead of popening getenforce-setenforce tools

    Credits:

    - me and me :)


    Source code:

    - source code -> https://github.com/munjeni/super_image_dumper
    18
    I'm not one of those who make paid software and promote on xda, my work is always free. Even I'm always providing source code for free, source code of this tool is here -> https://github.com/munjeni/super_image_dumper , enjoy! ;)
    3
    Version 7 is out! V6 had error detecting slinux status. I do not have device with super partition for test my tool but I have only hope that all is ok. Let me know! :)
    3
    Pixel 4a, working. V13
    3
    how about simg2img