Yes that one works great, the attrib labels were wrong in the other one. Thanks for the working script Zach!
Just a minor cosmetic bug, partition sizes are printed twice. The reason why is not at all obvious in the script.
Code:
Size for partition file ./system.img is 609792000
Size for partition file ./vendor.img is 261836800
Size for partition file ./odm.img is 2633728
Size for partition file ./product.img is 496869376
Size for partition file ./system.img is 609792000
Size for partition file ./vendor.img is 261836800
Size for partition file ./odm.img is 2633728
Size for partition file ./product.img is 496869376
./lpmake --metadata-size 65536 --metadata-slots 1 --device super:1677721600 --group main:1371131904 --partition system:readonly:609792000:main --image system=./system.img --partition vendor:readonly:261836800:main --image vendor=./vendor.img --partition odm:readonly:2633728:main --image odm=./odm.img --partition product:readonly:496869376:main --image product=./product.img --sparse --output ./super.new.img
lpmake I 08-12 22:52:49 22525 22525 builder.cpp:1012] [liblp]Partition system will resize from 0 bytes to 609792000 bytes
lpmake I 08-12 22:52:49 22525 22525 builder.cpp:1012] [liblp]Partition vendor will resize from 0 bytes to 261836800 bytes
lpmake I 08-12 22:52:49 22525 22525 builder.cpp:1012] [liblp]Partition odm will resize from 0 bytes to 2633728 bytes
lpmake I 08-12 22:52:49 22525 22525 builder.cpp:1012] [liblp]Partition product will resize from 0 bytes to 496869376 bytes
Invalid sparse file format at header magic
Invalid sparse file format at header magic
Invalid sparse file format at header magic
Invalid sparse file format at header magic
This version of lpunpack doesn't work on Android 11 super images. Allways this error:
lpunpack E 08-25 17:54:01 2064 2064 reader.cpp:171] [liblp]Logical partition metadata has invalid checksum.
lpunpack E 08-25 17:54:02 2064 2064 reader.cpp:171] [liblp]Logical partition metadata has invalid checksum.
Image does not appear to be in super-partition format.!
android super.img tools. Contribute to LonelyFool/lpunpack_and_lpmake development by creating an account on GitHub.
github.com
but I dont't get to build it, allways several errors.
Could you try to build lpunpack (and lpmake, they are together) and post it here?
Thanks in advance.
Hello and welcome to my first post.
today I will talk about editing super.img and modifying system.img inside of it.
In android 10 and bigger, sometimes there is no system.img in ROM it because google starting use Dynamic Partitions for more flexible images size - more details here
instead of system.img we will see super.img that include few partition inside.
So In this case, in order to do our modifications in the rom we should unpack the super.img and after that to unpack the system.img and then build it again.
requirements:
1) I will use ubuntu in vbox so you need a linux machine.
2) some super.img for editing.
steps:
1) unpacking super.img
2) resizing system.img in order to insert our MODS to the rom
3) mounting system.img
4) do our modifications
5) umounting system
6) shrink edited system.img to the minimal size
7) generating new super.img
8) flashing it to our device
Let's Start! 1) unpacking super image:
First of all the super.img file might be in sparse format so we need to make it raw image
open termianl in super.img directory and type:
Code:
simg2img super.img super.ext4.img
now we got new file named super.ext4.img: we are working with this file.
There are multiple ways to unpack super.img:
for example: using imjtool or using lpunpack
If you use imjtool follow this
Open terminal in imjtool path and super.img path and type
Code:
./imjtool.ELF64 super.img extract
if you got and error run it as superuser by
Code:
sudo ./imjtool.ELF64 super.img extract
I will use lpunpck tool (Official tool from google)
locate lpunpack and super.ext4.img and open terminal in this folder.
Then type:
Code:
./lpunpack super.ext4.img
wait for it it may take couple of minutes.
now our folder looks like this:
2)resizing system.img in order to make enough space for modifications
turn back into your terminal and type:
Code:
fallocate -l 2G system.img
This command allocates more space for system.img (Changing to 2GB)
After that type:
Code:
resize2fs system.img 2G
This command increases the file system size of the partition to 2G
3) mounting system.img
Create new folder and mount:
Code:
mkdir system
Code:
sudo mount -t ext4 -o loop system.img system
Now system dir contains all system.img files. 4)edit it as you want ***IMPORTANT***
In order to make changes you should use superuser:
when you typing a command while you modifying use sudo prefix.
you can use the file explorer with superuser permissions by typing:
Code:
sudo nautilus
5) umount system
*)make sure the terminal is not in system directory or some sub dir of it
if Yes just type
Code:
cd ..
to go up in the directories tree (do it many times until you will be in the same directory like the image in the top)
type:
Code:
sudo umount system
Code:
e2fsck -yf system.img
(fixes file system errors) 6) shrink the edit system.img into the minimum possible size
by:
Code:
resize2fs -M system.img
fix the file system again:
Code:
e2fsck -yf system.img
7) generating new super.img
as you can see at the image above, in my case the super.ext4.img contaings 3 partitions:
1)system.img(that we worked with)
2)vendor.img
3)product.img
in you case it may be different so follow the logic of the following command and not copy paste it.
another tool from google that called lpmake using for packing super.img.
How this tool works
it creates empty super.img with all headers stuff and pushing partitions into it
so let's start with generating:
this is the documentation of the tool: link
at first we should get each partitions file size
we can do it by:
Code:
stat -c '%n %s' system.img
do it for all partitions files
And this is tricky and critical step: ***DO NOT COPY!!***
explanation:
1) --metadata-size: The maximum size that partition metadata may consume. A partition entry uses 64 bytes and an extent entry uses 16 bytes. I think 65536 should work in most cases.
2) --metadata-slots - The number of slots available for storing metadata. This should match the number of update slots on the device, 2 for A/B devices and 1 for non-A/B.
3)--device super: The size of the “super” partition on the device. It must match exactly, and it must be evenly divisible by the sector size (512 bytes).
4) --group main:4293513600: sum of all partitions files sizes
5) --partition system:readonly:1577095168:main --image system=./system.img : Every parition file size with permissions(readonly) and input img file
8) flashing the new rom to a physical device First of all we should unlock the boot loader without unlocking we may brick the phone
It can be done by allowing oem unlock in developers options and rebooting into bootloader and type:
Code:
fastboot flashing unlock
But it may not work - it depends on your device so check in google.
After you unlocked the bootloader flash the new rom by:
Code:
fastboot flash super super.new.img
If your devices alert for unlocked bootloader(orange state)
you can remove this annoying alert
just search on google.
if you have mediatek check this link: https://forum.hovatek.com/thread-31664.html
Hello and welcome to my first post.
today I will talk about editing super.img and modifying system.img inside of it.
In android 10 and bigger, sometimes there is no system.img in ROM it because google starting use Dynamic Partitions for more flexible images size - more details here
instead of system.img we will see super.img that include few partition inside.
So In this case, in order to do our modifications in the rom we should unpack the super.img and after that to unpack the system.img and then build it again.
requirements:
1) I will use ubuntu in vbox so you need a linux machine.
2) some super.img for editing.
steps:
1) unpacking super.img
2) resizing system.img in order to insert our MODS to the rom
3) mounting system.img
4) do our modifications
5) umounting system
6) shrink edited system.img to the minimal size
7) generating new super.img
8) flashing it to our device
Let's Start! 1) unpacking super image:
First of all the super.img file might be in sparse format so we need to make it raw image
open termianl in super.img directory and type:
Code:
simg2img super.img super.ext4.img
now we got new file named super.ext4.img: we are working with this file.
There are multiple ways to unpack super.img:
for example: using imjtool or using lpunpack
If you use imjtool follow this
Open terminal in imjtool path and super.img path and type
Code:
./imjtool.ELF64 super.img extract
if you got and error run it as superuser by
Code:
sudo ./imjtool.ELF64 super.img extract
I will use lpunpck tool (Official tool from google)
locate lpunpack and super.ext4.img and open terminal in this folder.
Then type:
Code:
./lpunpack super.ext4.img
wait for it it may take couple of minutes.
now our folder looks like this:
2)resizing system.img in order to make enough space for modifications
turn back into your terminal and type:
Code:
fallocate -l 2G system.img
This command allocates more space for system.img (Changing to 2GB)
After that type:
Code:
resize2fs system.img 2G
This command increases the file system size of the partition to 2G
3) mounting system.img
Create new folder and mount:
Code:
mkdir system
Code:
sudo mount -t ext4 -o loop system.img system
Now system dir contains all system.img files. 4)edit it as you want ***IMPORTANT***
In order to make changes you should use superuser:
when you typing a command while you modifying use sudo prefix.
you can use the file explorer with superuser permissions by typing:
Code:
sudo nautilus
5) umount system
*)make sure the terminal is not in system directory or some sub dir of it
if Yes just type
Code:
cd ..
to go up in the directories tree (do it many times until you will be in the same directory like the image in the top)
type:
Code:
sudo umount system
Code:
e2fsck -yf system.img
(fixes file system errors) 6) shrink the edit system.img into the minimum possible size
by:
Code:
resize2fs -M system.img
fix the file system again:
Code:
e2fsck -yf system.img
7) generating new super.img
as you can see at the image above, in my case the super.ext4.img contaings 3 partitions:
1)system.img(that we worked with)
2)vendor.img
3)product.img
in you case it may be different so follow the logic of the following command and not copy paste it.
another tool from google that called lpmake using for packing super.img.
How this tool works
it creates empty super.img with all headers stuff and pushing partitions into it
so let's start with generating:
this is the documentation of the tool: link
at first we should get each partitions file size
we can do it by:
Code:
stat -c '%n %s' system.img
do it for all partitions files
And this is tricky and critical step: ***DO NOT COPY!!***
explanation:
1) --metadata-size: The maximum size that partition metadata may consume. A partition entry uses 64 bytes and an extent entry uses 16 bytes. I think 65536 should work in most cases.
2) --metadata-slots - The number of slots available for storing metadata. This should match the number of update slots on the device, 2 for A/B devices and 1 for non-A/B.
3)--device super: The size of the “super” partition on the device. It must match exactly, and it must be evenly divisible by the sector size (512 bytes).
4) --group main:4293513600: sum of all partitions files sizes
5) --partition system:readonly:1577095168:main --image system=./system.img : Every parition file size with permissions(readonly) and input img file
8) flashing the new rom to a physical device First of all we should unlock the boot loader without unlocking we may brick the phone
It can be done by allowing oem unlock in developers options and rebooting into bootloader and type:
Code:
fastboot flashing unlock
But it may not work - it depends on your device so check in google.
After you unlocked the bootloader flash the new rom by:
Code:
fastboot flash super super.new.img
If your devices alert for unlocked bootloader(orange state)
you can remove this annoying alert
just search on google.
if you have mediatek check this link: https://forum.hovatek.com/thread-31664.html
I have followed your instructions in order to edit the init.rc file to alter the boot on charge power behaviour for a Samsung A3. When I try and use Odin to reflash the phone - I end up with an error screen showing vbmeta HASH_MISMATCH
I have followed your instructions in order to edit the init.rc file to alter the boot on charge power behaviour for a Samsung A3. When I try and use Odin to reflash the phone - I end up with an error screen showing vbmeta HASH_MISMATCH
Hi. Did you try disable dm-verity and verification? There is avbctl binary in my SystemRW project that can do this. Maybe it helps with booting.
I know Samsung deleted fastboot from all their devices which is a shame otherwise you could also use that for disabling dm-verity by flashing empty vbmeta with special parameters:
help. problem is junk apps will recover when system run without root (restart phone to lost root) even its folder in priv-app has been deleted. how do i solve it? anyone know how to completely delete it? I can't identify these bloatware, it only appear when unroot, disappear when root. No way to uninstall it normally, I need help to find the folder of these bloatware and delete it. i think it can only remove folder in system/app or priv-app to remove bloatware. this is the case especially when i unroot it shows up again. And the additional download file managers can't show them to know directory where it's installed from, this special bloatware simply doesn't work using system/app. So anyone with a solution please help<- my bad englísh
help. problem is junk apps will recover when system run without root (restart phone to lost root) even its folder in priv-app has been deleted. how do i solve it? anyone know how to completely delete it? I can't identify these bloatware, it only appear when unroot, disappear when root. No way to uninstall it normally, I need help to find the folder of these bloatware and delete it. i think it can only remove folder in system/app or priv-app to remove bloatware. this is the case especially when i unroot it shows up again. And the additional download file managers can't show them to know directory where it's installed from, this special bloatware simply doesn't work using system/app. So anyone with a solution please help<- my bad englísh
Im in custom ROM (rooted). My partition system is dynamic, using system as root and rooting it's not easy
.
If apps are restored, you can't have system root. seems to me you onely have partial root. If so. you dont actually delete the apps. You only disables them for user 0.
Try this:
adb shell pm uninstall -k --user 0 XXXXXNAME of you app
I guessed wrong, when booting without root bloatware will reinstall itself to the system folder. Help me find the cause and how to fix it. Above command not executing, when re-enable root by booting into recovery i got into data/user/0 but no bloatware folder, bloatware folder in system app also disappeared.
I guessed wrong, when booting without root bloatware will reinstall itself to the system folder. Help me find the cause and how to fix it. Above command not executing, when re-enable root by booting into recovery i got into data/user/0 but no bloatware folder, bloatware folder in system app also disappeared.
this uninstallation is only temporary for the user, i checked the system partition again and was surprised to notice that all my junk delete modifications are stock restored. which contains a whole list of junk apps will be installed if i select india country because it has indian letters which i deleted as root, and many bloatware, junk subfolders are also restored in /system, inside system/app priv-app has the bloatware folder recover and the uninstall command is just a command to hide it from the user. maybe you need an itel p15 w5005p like me to understand it clearly. i don't know how it restores and where is this backup file, I have to edit system.img? note I won't be able to find bloatware packages with adb shell as root because they will disappear (delete) with the modification I did. i can only uninstall if i unroot and bloatware they recover up. my phone use system as root and ram disk is in recovery. whenever want to flash an image or modify a file that vbmeta will verify the file must be signed and edited vbmeta otherwise the system will not boot. That's my phone system. When I used the first command without root I got: internal memory error. I tried the second command and it didn't remove the bloatware folder in /system, the apk files were still intact. it just makes the app disappear from the screen.
this uninstallation is only temporary for the user, i checked the system partition again and was surprised to notice that all my junk delete modifications are stock restored. which contains a whole list of junk apps will be installed if i select india country because it has indian letters which i deleted as root, and many bloatware, junk subfolders are also restored in /system, inside system/app priv-app has the bloatware folder recover and the uninstall command is just a command to hide it from the user. maybe you need an itel p15 w5005p like me to understand it clearly. i don't know how it restores and where is this backup file, I have to edit system.img? note I won't be able to find bloatware packages with adb shell as root because they will disappear (delete) with the modification I did. i can only uninstall if i unroot and bloatware they recover up. my phone use system as root and ram disk is in recovery. whenever want to flash an image or modify a file that vbmeta will verify the file must be signed and edited vbmeta otherwise the system will not boot. That's my phone system. When I used the first command without root I got: internal memory error. I tried the second command and it didn't remove the bloatware folder in /system, the apk files were still intact. it just makes the app disappear from the screen.
Yes my friend. as I said. you don't have system root. You only have partial root.
But yes, you can deconstruct your phones firmware and make your changes, and compile the rom back together and flash it. It's exactly what a custom rom is. My suggestion is that you find a custom rom you like and flash it over your original. That way, you circumvent the problem.
is my root just a user instance with more permissions? when i make changes in system is it just fake for "user with multiple permissions" does it have no real impact on the system?
First disable the annoying bloatware and then reboot your device a couple of times. If no bootloop or other errors then it's safe to delete it with your favorite root file browser app. Make sure to mount your partition as rw before trying to delete files off it (see image below) !
Good luck!
Hello and welcome to my first post.
today I will talk about editing super.img and modifying system.img inside of it.
In android 10 and bigger, sometimes there is no system.img in ROM it because google starting use Dynamic Partitions for more flexible images size - more details here
instead of system.img we will see super.img that include few partition inside.
So In this case, in order to do our modifications in the rom we should unpack the super.img and after that to unpack the system.img and then build it again.
requirements:
1) I will use ubuntu in vbox so you need a linux machine.
2) some super.img for editing.
steps:
1) unpacking super.img
2) resizing system.img in order to insert our MODS to the rom
3) mounting system.img
4) do our modifications
5) umounting system
6) shrink edited system.img to the minimal size
7) generating new super.img
8) flashing it to our device
Let's Start! 1) unpacking super image:
First of all the super.img file might be in sparse format so we need to make it raw image
open termianl in super.img directory and type:
Code:
simg2img super.img super.ext4.img
now we got new file named super.ext4.img: we are working with this file.
There are multiple ways to unpack super.img:
for example: using imjtool or using lpunpack
If you use imjtool follow this
Open terminal in imjtool path and super.img path and type
Code:
./imjtool.ELF64 super.img extract
if you got and error run it as superuser by
Code:
sudo ./imjtool.ELF64 super.img extract
I will use lpunpck tool (Official tool from google)
locate lpunpack and super.ext4.img and open terminal in this folder.
Then type:
Code:
./lpunpack super.ext4.img
wait for it it may take couple of minutes.
now our folder looks like this:
2)resizing system.img in order to make enough space for modifications
turn back into your terminal and type:
Code:
fallocate -l 2G system.img
This command allocates more space for system.img (Changing to 2GB)
After that type:
Code:
resize2fs system.img 2G
This command increases the file system size of the partition to 2G
3) mounting system.img
Create new folder and mount:
Code:
mkdir system
Code:
sudo mount -t ext4 -o loop system.img system
Now system dir contains all system.img files. 4)edit it as you want ***IMPORTANT***
In order to make changes you should use superuser:
when you typing a command while you modifying use sudo prefix.
you can use the file explorer with superuser permissions by typing:
Code:
sudo nautilus
5) umount system *)make sure the terminal is not in system directory or some sub dir of it
if Yes just type
Code:
cd ..
to go up in the directories tree (do it many times until you will be in the same directory like the image in the top)
type:
Code:
sudo umount system
Code:
e2fsck -yf system.img
(fixes file system errors) 6) shrink the edit system.img into the minimum possible size
by:
Code:
resize2fs -M system.img
fix the file system again:
Code:
e2fsck -yf system.img
7) generating new super.img
as you can see at the image above, in my case the super.ext4.img contaings 3 partitions:
1)system.img(that we worked with)
2)vendor.img
3)product.img
in you case it may be different so follow the logic of the following command and not copy paste it.
another tool from google that called lpmake using for packing super.img.
How this tool works
it creates empty super.img with all headers stuff and pushing partitions into it
so let's start with generating:
this is the documentation of the tool: link
at first we should get each partitions file size
we can do it by:
Code:
stat -c '%n %s' system.img
do it for all partitions files
And this is tricky and critical step: ***DO NOT COPY!!***
explanation:
1) --metadata-size: The maximum size that partition metadata may consume. A partition entry uses 64 bytes and an extent entry uses 16 bytes. I think 65536 should work in most cases.
2) --metadata-slots - The number of slots available for storing metadata. This should match the number of update slots on the device, 2 for A/B devices and 1 for non-A/B.
3)--device super: The size of the “super” partition on the device. It must match exactly, and it must be evenly divisible by the sector size (512 bytes).
4) --group main:4293513600: sum of all partitions files sizes
5) --partition system:readonly:1577095168:main --image system=./system.img : Every parition file size with permissions(readonly) and input img file
8) flashing the new rom to a physical device First of all we should unlock the boot loader without unlocking we may brick the phone
It can be done by allowing oem unlock in developers options and rebooting into bootloader and type:
Code:
fastboot flashing unlock
But it may not work - it depends on your device so check in google.
After you unlocked the bootloader flash the new rom by:
Code:
fastboot flash super super.new.img
If your devices alert for unlocked bootloader(orange state)
you can remove this annoying alert
just search on google.
if you have mediatek check this link: https://forum.hovatek.com/thread-31664.html
Hey dear thank you for the compliment, please tell me more about how did you flash the new image.
hey dear did you flash it by using sp flash tool? did you unlocked the bootloader? did you see orange state warning when the device booted after flashing?
I've unlocked the bootloader as you oriented, and after that, I'm seeing the orange warning!I tried flashing using two methods. Using SP Flash Tool, and using flashboot.
Using SP Flash Tool was straight forward. Just selected the Scatter File, then picked the new super.img. Successfully flashed, but no changes on the phone.
Using flashboot: ./flashboot flash super super.modified.img
What a did, in short, was:
1.) simg2img super.img super.raw
2.) imjtool super.raw extract (also tried using lpunpack as you oriented)
3.) mount -t ext4 -o loop system.img /mount/point
4.) edit everything needed
5.) umount /mount/point
6.) repacked super.img using lpmake
7.) flashed the new super.img using SPFT or flashboot. Boths succeeds, but none really modifies the phone
To double check that the new super.img is correct, I've extracted it again, and double checked my changes. and they are there.
I made a Python script to make repacking a super.img a little easier. To use it, you'll need Python 3 and `argparse` installed (`pip3 install argparse`). You'll also need `lpmake` available somewhere (you can download a prebuilt version here: https://forum.xda-developers.com/t/guide-ota-tools-lpunpack.4041843/).
Basic usage can be seen by running `python3 lpmakesimple.py -h`.
An example would be: `python3 lpmakesimple.py ./lpmake ./super.new.img 4294967296 system=./system.img,vendor=./vendor.img,product=./product.img`
@Brepro1 thank you so much for writing this detailed guide.
Thanks to your detailed guide I was able to create an automated bash script that performs all of these steps automatically and makes all read only partitions inside super.img (system, vendor , product, etc...) into read write-able partitions again and flash to device as a brand new super.img.
It would be an honor for me if you could please try it and let me know if it works on your device. Thanks.