[Tool] SparseConverter v1.0.1 - Android General

About:
fastboot stores each file it receives in RAM before flashing it to your Android device.
For this reason, large partitions (such as the /system partition) must be splitted using the "compressed ext4 file system sparse image format",
this format is defined by the AOSP (Android Open Source Project) and was designed for the single purpose of flashing a large partition.
If you tried to flash system.img from backup and received the "Invalid sparse file format at header magi" error, you have come to the right place.
The Solution:
SparseConverter is a tool that can create / decompress compressed ext4 file system sparse image format (e.g. system.img_sparsechunk1).
Note for Motorola phone owners:
The factory images from Motorola contains a 128KB motorola header and a 4KB motorola footer, if you decompress those images you may want to remove the header and footer.
I had no problem using the standard Android fastboot with my unlocked Moto G and flashing images without the Motorola header / footer.
(If you keep the header / footer, then you must use Motorola's fastboot)
Usage Examples:
SparseConverter.exe /compress D:\system.img E:\ 256MB
( will compress D:\system.img to 256MB sparse files starting from E:\system.img_sparsechunk1 )
SparseConverter.exe /decompress E:\system.img_sparsechunk1 D:\system.img
( will decompress E:\system.img_sparsechunk1, E:\system.img_sparsechunk2 and etc. to D:\system.img )
The software may contain bugs and/or limitations that may result in damage to your phone, I take no responsibility for any damage that may occur.
For additional information about the "compressed ext4 file system sparse image format" see libsparse/sparse_format.h
p.s. Source code in C# is provided, Windows XP \ 2003 users must install the .Net Framework 2.0 before running this tool.

How can i flash system.img when is too large. i have compressed it using this tool, now how to flash?

Everything is explained in the original post, You need to use fastboot.exe which is part of the ADT bundle (Android Development Tools).

tal.aloni said:
Everything is explained in the original post, You need to use fastboot.exe which is part of the ADT bundle (Android Development Tools).
Click to expand...
Click to collapse
fastboot flash system system.img_sparsechunk1 ?
Not working for me. :/
It will be downloaded to device, but not flashed.

yes,
fastboot flash system system.img_sparsechunk1
fastboot flash system system.img_sparsechunk2
fastboot flash system system.img_sparsechunk3
make sure the system partition size match the image that you're trying to flash, to flash a bigger image you'll have to reflash the partition table and all the partitions (boot, recovery etc.)
p.s. not sure what "not working" means, what error do you get exactly?

tal.aloni said:
yes,
fastboot flash system system.img_sparsechunk1
fastboot flash system system.img_sparsechunk2
fastboot flash system system.img_sparsechunk3
make sure the system partition size match the image that you're trying to flash, to flash a bigger image you'll have to reflash the partition table and all the partitions (boot, recovery etc.)
p.s. not sure what "not working" means, what error do you get exactly?
Click to expand...
Click to collapse
Here is my error code, after attemp to flash system system.img_sparechunk1:
FAILED (remote: flash_cmds error!)
partition size match, it is system dump from another same device.

Sorry, I'm not familiar with this error.

tal.aloni said:
Sorry, I'm not familiar with this error.
Click to expand...
Click to collapse
I have Rooted my ASUS Tablet, and deleted something in system, now i am soft-bricked.
Now i cannot do somethnig, only use fastboot, butt i cannot flash system.
So i must waiting to developers, to port CWM/TWRP for my device.

Hi, I'm trying to convert a userdata.img file (60GB!) so I can flash it with fastboot onto my phone, when I run the tool I get this
Code:
C:\Users\Matt\Documents\SparseConverter_1.0.0>sparseconverter /compress C:\Users
\Matt\Documents\userdata.img "C:\Users\Matt\Documents\userdata sparse" 256MB
Image size is not a multiple of 4096 bytes
Does this mean that it won't convert my image? Thanks
EDIT: Also I know this image is valid as under linux
Code:
[email protected]:~$ sudo mount -t ext4 -o loop /home/matt/userdata.img /home/matt/ext4
[sudo] password for matt:
[email protected]:~$ sudo su
[email protected]:/home/matt# cd ext4
[email protected]:/home/matt/ext4# ls
anr bugreports dontpanic media resource-cache user
app cam_socket1 dpm mediadrm security
app-asec cam_socket2 drm misc shared
app-lib connectivity fdAlbum nfc system
app-private dalvik-cache local opponvitems time
backup data lost+found property tombstones

Hi Matt,
ext4 allocates storage space in units of "blocks". A block is a group of sectors between 1KiB and 64KiB, and the number of sectors must be an integral power of 2. Block size is specified at mkfs time and typically is 4KiB.
Click to expand...
Click to collapse
The sector size for most flash devices is 4096 bytes.
The "compressed ext4 file system sparse image format" assumes that the image is going to be flashed to a flash device, and thus expects its size to be a multiple of 4096 bytes.
I'm not sure how you created this user data partition image, the size of a proper image (for flashing purposes) should be a multiple of 4096 bytes.
Edit: BlockSize can be set to 512 instead of 4096 in SparseConverter source code (SparseCompressionHelper.cs).

tal.aloni said:
Hi Matt,
The sector size for most flash devices is 4096 bytes.
The "compressed ext4 file system sparse image format" assumes that the image is going to be flashed to a flash device, and thus expects its size to be a multiple of 4096 bytes.
I'm not sure how you created this user data partition image, the size of a proper image (for flashing purposes) should be a multiple of 4096 bytes.
Click to expand...
Click to collapse
I ran into this issue as well. I am trying to compress the userdata image from my phone that was previously bricked and I'd like to find a way to hold onto this data.
Thank you!

hazard666 said:
I ran into this issue as well. I am trying to compress the userdata image from my phone that was previously bricked and I'd like to find a way to hold onto this data.
Thank you!
Click to expand...
Click to collapse
How did you create this image? are you sure it's a raw image?
if it's indeed a raw image, you could append a the necessary amount of zero bytes to the image (e.g. using HxD) and then you could compress it.
I'm not sure what you mean by "hold onto this data", this tool is to prepare an image for flashing, if you're trying to access the files there are other methods (e.g. linux).

Awesome, I use this tool to compress system file of Motorola X2014 of 2.7GB that I was not able to flash it... works great, thank you so much

Great progress! In my case
I generate my system.img.raw by
adb root
adb wait-for-device
adb shell "dd if=/dev/block/platform/f9824900.sdhci/by-name/system of=/sdcard/system.img.raw"
adb pull -p /sdcard/system.img.raw
1st Trail below will NOT works, but at the end you will see my solution:
Windows cmd log:
E:\AzlunData\DEV Tools\ImageBakupsCMD\SYS GMS+Root+AzAppsMDP>sparseconverter /compress system.img.raw .\ 536870912
...
pause
E:\AzlunData\DEV Tools\ImageBakupsCMD\SYS GMS+Root+AzAppsMDP>fastboot flash system system.img.raw_
sparsechunk1
target reported max download size of 536870912 bytes
erasing 'system'...
OKAY [ 0.591s]
sending 'system' (524284 KB)...
OKAY [ 1.350s]
writing 'system'...
OKAY [ 13.953s]
finished. total time: 15.897s
E:\AzlunData\DEV Tools\ImageBakupsCMD\SYS GMS+Root+AzAppsMDP>fastboot flash system system.img.raw_
sparsechunk2
target reported max download size of 536870912 bytes
erasing 'system'...
OKAY [ 0.532s]
sending 'system' (524287 KB)...
OKAY [ 1.351s]
writing 'system'...
OKAY [ 8.678s]
finished. total time: 10.565s
E:\AzlunData\DEV Tools\ImageBakupsCMD\SYS GMS+Root+AzAppsMDP>fastboot flash system system.img.raw_
sparsechunk3
target reported max download size of 536870912 bytes
erasing 'system'...
OKAY [ 0.524s]
sending 'system' (411515 KB)...
OKAY [ 1.075s]
writing 'system'...
OKAY [123.069s]
finished. total time: 124.671s
Please note even we pass the fastboot flashing, but it does NOT works after flash is finished, the phone can reboot to Linux logo, but block there, can not start Android Animation and go to desktop.
E:\AzlunData\DEV Tools\ImageBakupsCMD\SYS GMS+Root+AzAppsMDP>adb shell
- exec '/system/bin/sh' failed: No such file or directory (2) -
SO, SOLUTION is:
as an conclusion, it seems fastboot can not manage the multi input images well, BUT it can handle a single compressed image files, so set the max image side to the partition size to 2684354560 can make fastboot works well.
I need to find my original dd output file system.img.raw in 2.5GB, then:
Windows cmd logs:
E:\AzlunData\DEV Tools\ImageBakupsCMD\SYS GMS+Root+AzAppsMDP>sparseconverter /compress system.img.raw .\ 2684354560
E:\AzlunData\DEV Tools\ImageBakupsCMD\SYS GMS+Root+AzAppsMDP>fastboot flash system system.img.raw_sp
arsechunk1
target reported max download size of 536870912 bytes
erasing 'system'...
OKAY [ 0.767s]
sending sparse 'system' (521371 KB)...
OKAY [ 4.530s]
writing 'system'...
OKAY [ 9.577s]
sending sparse 'system' (511116 KB)...
OKAY [ 6.465s]
writing 'system'...
OKAY [ 10.833s]
sending sparse 'system' (445892 KB)...
OKAY [ 6.274s]
writing 'system'...
OKAY [139.377s]
finished. total time: 177.831s
that will bring my system.img.raw back to my phone WELL
you can see my rooted su is there, ^_^:
E:\AzlunData\DEV Tools\ImageBakupsCMD\SYS GMS+Root+AzAppsMDP>adb shell
[email protected]:/ $ su
su
[email protected]:/ #

Matt, hazard666,
I was wrong, there is no restriction on BlockSize , you're welcome to download SparseConverter source code and set BlockSize to 512 (in SparseCompressionHelper.cs),
please let me know if this helps.

tal.aloni said:
Note for Motorola phone owners:
The factory images from Motorola contains a 128KB motorola header and a 4KB motorola footer, if you decompress those images you may want to remove the header and footer.
I had no problem using the standard Android fastboot with my unlocked Moto G and flashing images without the Motorola header / footer.
(If you keep the header / footer, then you must use Motorola's fastboot)
Click to expand...
Click to collapse
Hi, I used your tool to decompress sparsechunks into a single system image for the Moto X 2014 XT1097, AT&T. This is needed as a preliminary step in order to get root.
The next step is to convert the image into an ext4 format. However, the instructions we have to do that require using linux command simg2img and it doesn't like the header. The errors are:
"Invalid sparse file format at header magi
Failed to read sparse file"
"Bad magic"
or
"Error reading sparse file header"
How do we get rid of this header? Thanks!

JulesJam said:
How do we get rid of this header? Thanks!
Click to expand...
Click to collapse
I usually do it manually with HxD (hex editor).
JulesJam said:
The next step is to convert the image into an ext4 format. However, the instructions we have to do that require using linux command simg2img and it doesn't like the header.
Click to expand...
Click to collapse
I think you're confused, once the image is decompressed, it's no longer a sparse file, you shouldn't use simg2img (to convert it to raw image, because it's already been done).
instead, you can just mount the image, for ext4 it would be:
Code:
sudo mount -t ext4 -o loop,offset=131072 system.img mnt/
and when you're done customizing:
Code:
sudo ./make_ext4fs -l 840M -a system mysystem.img mnt/
sudo umount mnt
(note that I've used offset=131072 instead of removing the header)

tal.aloni said:
I think you're confused, once the image is decompressed, it's no longer a sparse file, so you shouldn't use simg2img.
Click to expand...
Click to collapse
Yeah, I am definitely confused, lol!
tal.aloni said:
instead, use something along the line of (note that I've used offset=131072 instead of removing the header):
Code:
sudo mount -t ext4 -o loop,offset=131072 system.img mnt/
sudo ./make_ext4fs -l 840M -a system mysystem.img mnt/
sudo umount mnt
Click to expand...
Click to collapse
Ok great, I will have someone who knows linux try that. What we want is a single file system image in ext4 format so hopefully that will work!
Thanks!

tal.aloni said:
I usually do it manually with HxD (hex editor).
I think you're confused, once the image is decompressed, it's no longer a sparse file, you shouldn't use simg2img (to convert it to raw image, because it's already been done).
instead, you can just mount the image, for ext4 it would be:
Code:
sudo mount -t ext4 -o loop,offset=131072 system.img mnt/
and when you're done customizing:
Code:
sudo ./make_ext4fs -l 840M -a system mysystem.img mnt/
sudo umount mnt
(note that I've used offset=131072 instead of removing the header)
Click to expand...
Click to collapse
JulesJam said:
Yeah, I am definitely confused, lol!
Ok great, I will have someone who knows linux try that. What we want is a single file system image in ext4 format so hopefully that will work!
Thanks!
Click to expand...
Click to collapse
And I'm someone who's running a Linux distro!
After the second command I'm getting a memory allocation error though
"error: do_inode_allocate_extents: Failed to allocate 6524 blocks"

tal.aloni said:
I think you're confused, once the image is decompressed, it's no longer a sparse file, you shouldn't use simg2img (to convert it to raw image, because it's already been done).
Click to expand...
Click to collapse
Also, just to be complete, the way I am going to modify/root the ext4 image is by using TWRP on a bootloader unlocked device according to these instructions:
http://forum.xda-developers.com/showpost.php?p=60389310&postcount=177
It worked for the XT1096 so it should work for the XT1097. Once we get the rooted ext4 image, we have a tool to flash it to the XT1097 that bypasses the signature check. Our bootloaders are locked so we have to do it this way.

Related

[GUIDE][BRICKED] [BOOTS ONLY TO RECOVERY][All ASUS TRANFORMERS]

This is a general users guide to unbrick your Transformer tablet.
This guide will help you if your Asus tablet will only boot into recovery
and the command
Code:
adb reboot-bootloader
does not work to get you booted back to bootloader screen ..
If the above command works then skip to the first fastboot command ..
WHAT YOU NEED
An Asus tablet that will only boot into recovery …
Woking adb and fastboot on your PC
Windows drivers (if using Windows)
A fully charged tablet
Asus data cable
Stock firmware blob (from Asus's web site, make sure you get the right one)
_that's bootit.ko (unzipped and placed with fastboot.exe)
Downloads
Asus Stock firmware---MAKE SURE YOU GET THE CORRECT SKU FOR YOUR TRANSFORMER TABLET
click me
_that's bootit.ko----click me
INSTRUCTIONS
Extract your stock firmware in your downloads folder twice...You will see a blob file rename it boot.blob and move it to the same folder as your fastboot.exe or if in linux to your home folder
Unzip the bootit.ko and place it wth the above blob file.
Let start with this command to make sure that your PC can see your table as an ADB device in recovery
Code:
adb devices
OUTPUT
Code:
[email protected] ~ $ adb devices
List of devices attached
015c7d7a445c260c recovery
Then lets push the bootit.ko to the root of the device like this
Code:
adb push bootit.ko /
OUTPUT
Code:
[email protected] ~ $ adb push bootit.ko /
673 KB/s (27690 bytes in 0.040s)
Then lets insmod this .ko file
Code:
adb shell insmod /bootit.ko
This should reboot the tablet into the bootloader menu, lets verifiy.
Once in the bootloader screen lets make sure your PC can see the device in fastboot.
Code:
fastboot devices
OUTPUT
Code:
[email protected] ~ $ fastboot devices
015c7d7a445c260c fastboot
So now its time to erase the misc & cache partitions, as that is most likely the partitions that is making it boot to recovery...
Code:
fastboot erase misc
OUTPUT
Code:
[email protected] ~ $ fastboot erase misc
erasing 'misc'...
OKAY [ 1.021s]
finished. total time: 1.021s
Code:
fastboot erase cache
OUTPUT
Code:
[email protected] ~ $ fastboot erase cache
******** Did you mean to fastboot format this partition?
erasing 'cache'...
OKAY [ 2.096s]
finished. total time: 2.096s
Once these two command run with OKAY as the OUTPUT .
It is time to make sure we can reboot into the bootloader with the hardware buttons
So from where you are at in the bootloader screen use the VOL DOWN & POWER buttons to boot the tab back into the bootloader screen ..
Run these command in fastboot in this order
The next command is to just verify your computer can see your device
Code:
fastboot devices
OUTPUT
Code:
[email protected]:~ > fastboot devices
015d2bbce2501405 fastboot
Code:
fastboot erase system
OUTPUT
Code:
[email protected]:~ > fastboot erase system
******** Did you mean to fastboot format this partition?
erasing 'system'...
OKAY [ 2.954s]
finished. total time: 2.954s
Code:
fastboot erase recovery
OUTPUT
Code:
[email protected]:~ > fastboot erase recovery
erasing 'recovery'...
OKAY [ 1.945s]
finished. total time: 1.945s
Code:
fastboot -w
OUTPUT
Code:
[email protected]:~ > fastboot -w
erasing 'userdata'...
OKAY [ 23.188s]
formatting 'userdata' partition...
Creating filesystem with parameters:
Size: 29618601984
Block size: 4096
Blocks per group: 32768
Inodes per group: 8192
Inode size: 256
Journal blocks: 32768
Label:
Blocks: 7231104
Block groups: 221
Reserved block group size: 1024
Created filesystem with 11/1810432 inodes and 157662/7231104 blocks
sending 'userdata' (139133 KB)...
writing 'userdata'...
OKAY [ 26.358s]
erasing 'cache'...
At this point it will either hangs on erasing 'cache'
Or it will give you an error, either way you will need to
reboot the tablet back into fastboot with the hardware buttons
Once that is done continue on the path
Code:
fastboot erase boot
OUTPUT
Code:
[email protected]:~ > fastboot erase boot
erasing 'boot'...
OKAY [ 1.209s]
finished. total time: 1.209s
Code:
fastboot erase misc
OUTPUT
Code:
[email protected]:~ > fastboot erase misc
erasing 'misc'...
OKAY [ 0.978s]
finished. total time: 0.978s
Code:
fastboot erase cache
OUTPUT
Code:
[email protected]:~ > fastboot erase cache
******** Did you mean to fastboot format this partition?
erasing 'cache'...
OKAY [ 2.843s]
finished. total time: 2.843s
Code:
fastboot -i 0x0B05 flash system boot.blob
During the sending/writing process of this step you will get the blue bar on your screen.....
OUTPUT
Code:
[email protected]:~ > fastboot -i 0x0B05 flash system boot.blob
erasing 'system'...
OKAY [ 2.339s]
sending 'system' (800927 KB)...
OKAY [133.094s]
writing 'system'...
[OKAY [178.036s]
finished. total time: 313.469s
Code:
fastboot -i 0x0B05 reboot
OUTPUT
Code:
[email protected]:~ > fastboot -i 0x0B05 reboot
rebooting...
finished. total time: 0.020s
Let it boot into stock ROM ...
Credits
@_that for his bootit.ko
TEAM CROMBi and TEAM ZOMBi-X @sbdags @hardslog
Troubleshooting
Here is some troubleshooting
Check out this thread for fasboot.exe, adb.exe and driver help ...CLICK ME
@lj50036
A typo on your very first command: adb device?
Edit: What would you recommend if the userdata is corrupted and have only fastboot/adb? fastboot format data-partition? Thanks...
LetMeKnow said:
@lj50036
A typo on your very first command: adb device?
Edit: What would you recommend if the userdata is corrupted and have only fastboot/adb? fastboot format data-partition? Thanks...
Click to expand...
Click to collapse
Fixed let me know if you see anymore ..
Thx @LetMeKnow
LetMeKnow said:
@lj50036
A typo on your very first command: adb device?
Edit: What would you recommend if the userdata is corrupted and have only fastboot/adb? fastboot format data-partition? Thanks...
Click to expand...
Click to collapse
I am going to get to this once you have fastboot back and you can boot with hardware buttons then its just like @Buster99's
guide but there is one very important command that he leaves out ..
I will post the rest of the guide after bit ...
Thx Josh
Here is the original thread where the bootit module was tested for the first time -> http://forum.xda-developers.com/showthread.php?t=2291974
The problem was that the installed recovery was too old and incompatible with the bootloader and so could not access the eMMC at all. The bootloader command to boot to recovery is stored in the MSC partition (mmcblk0p3), and the recovery could not clear it. Since the bootloader checks the MSC partition before checking for volume-down, it is impossible to get to fastboot without some additional kick in the butt (aka "bootit.ko").
The correct bootit.ko file to use is the one in "bootit-bootloader.zip": http://forum.xda-developers.com/attachment.php?attachmentid=1985941&d=1369339132 - the older version turned out to be too weak. Note that this is a zipped kernel module, not a recovery-installable ZIP. You need to unzip it on your PC before adb push.
After making it to the bootloader menu and working fastboot, you can fastboot flash a current version of TWRP and install the custom ROM of your choice. No real need for the stock blob, unless you want to make sure you have the current bootloader and a known working ROM.
Here is another thread where bootit.ko didn't help, maybe it was really a hardware problem. But lots of good background info from me. -> http://forum.xda-developers.com/showthread.php?t=2437376
And here is another success story -> http://forum.xda-developers.com/showthread.php?p=47525770
_that said:
Here is the original thread where the bootit module was tested for the first time -> http://forum.xda-developers.com/showthread.php?t=2291974
The problem was that the installed recovery was too old and incompatible with the bootloader and so could not access the eMMC at all. The bootloader command to boot to recovery is stored in the MSC partition (mmcblk0p3), and the recovery could not clear it. Since the bootloader checks the MSC partition before checking for volume-down, it is impossible to get to fastboot without some additional kick in the butt (aka "bootit.ko").
The correct bootit.ko file to use is the one in "bootit-bootloader.zip": http://forum.xda-developers.com/attachment.php?attachmentid=1985941&d=1369339132 - the older version turned out to be too weak. Note that this is a zipped kernel module, not a recovery-installable ZIP. You need to unzip it on your PC before adb push.
After making it to the bootloader menu and working fastboot, you can fastboot flash a current version of TWRP and install the custom ROM of your choice. No real need for the stock blob, unless you want to make sure you have the current bootloader and a known working ROM.
Here is another thread where bootit.ko didn't help, maybe it was really a hardware problem. But lots of good background info from me. -> http://forum.xda-developers.com/showthread.php?t=2437376
And here is another success story -> http://forum.xda-developers.com/showthread.php?p=47525770
Click to expand...
Click to collapse
Thx _that I did update the OP with the correct bootit.ko ...
lj50036 said:
Thx _that I did update the OP with the correct bootit.ko ...
Click to expand...
Click to collapse
Great stuff! Thanks for this thread Josh!
Now , if I understand this correctly, the insmod command injects a command into the kernel to boot straight to the bootloader before checking misc to break that 'forced reboot to recovery' cycle.
Kinda correct?
In another thread @_that stated once that
Code:
fastboot getvar all
does not return misc as a supported partiton and that
Code:
fastboot erase misc
only "theoretically" erases misc partition. Is that confirmed now?
You guys are great! So much fun to learn this...
I tried to follow this but i get this output:
After pushing bootit.ko to the root and insmod, the transformer reboots directly in the bootloader.
When try fastboot devices, nothing happens just the next line to fill in a command.
Also, when trying then to fastboot erase misc, it hangs with 'waiting for devices'..
lvrijn said:
I tried to follow this but i get this output:
After pushing bootit.ko to the root and insmod, the transformer reboots directly in the bootloader.
When try fastboot devices, nothing happens just the next line to fill in a command.
Also, when trying then to fastboot erase misc, it hangs with 'waiting for devices'..
Click to expand...
Click to collapse
Did you have a working fastboot driver on your PC before you got into this pickle?
Give us a detailed description on why you tried this procedure.
berndblb said:
Did you have a working fastboot driver on your PC before you got into this pickle?
Give us a detailed description on why you tried this procedure.
Click to expand...
Click to collapse
Thanks for the advice.
It was not the driver, if was my fastboot and adb .exe, i think an old version?
I now downloaded from here http://forum.xda-developers.com/showthread.php?t=2588979
And these are working!
So if someone ever have problems command doesn't recognize fastboot commands, its not always the driver! It can also be the fastboot.exe
This transformer is working again !
lvrijn said:
Thanks for the advice.
It was not the driver, if was my fastboot and adb .exe, i think an old version?
I now downloaded from here http://forum.xda-developers.com/showthread.php?t=2588979
And these are working!
So if someone ever have problems command doesn't recognize fastboot commands, its not always the driver! It can also be the fastboot.exe
This transformer is working again !
Click to expand...
Click to collapse
Great to see you up and running...:good:
I did add a Troubleshooting post number 3
The Josh
berndblb said:
Great stuff! Thanks for this thread Josh!
Now , if I understand this correctly, the insmod command injects a command into the kernel to boot straight to the bootloader before checking misc to break that 'forced reboot to recovery' cycle.
Kinda correct?
In another thread @_that stated once that
Code:
fastboot getvar all
does not return misc as a supported partiton and that
Code:
fastboot erase misc
only "theoretically" erases misc partition. Is that confirmed now?
You guys are great! So much fun to learn this...
Click to expand...
Click to collapse
No, I dont think it injects anything into the kernel as there may not even be one in the LNX partition ..
The bootit.ko module comes from the source of the kernel code..
Also the /misc partition is a full partition as shown here ..
Code:
mmcblk0p3
Offset: 1292369920 (0x4d080000)
Size: 2097152 (0x200000)
File system size: 512 * 4096 = 2097152 (fully occupies partition)
Linux rev 1.0 ext3 filesystem
Not mounted
Permissions: GID system can manipulate
Contains: Empty file system
Purpose: Recovery /misc
Referenced by: /system/lib/libandroid_runtime.so recovery ramdisk: /etc/recovery.fstab
Note: File system is referenced in recovery as emmc, not ext3!
Thx Josh
lj50036 said:
No, I dont think it injects anything into the kernel as there may not even be one in the LNX partition ..
Click to expand...
Click to collapse
I think berndblb meant that insmod injects something into the *currently running* kernel, which it does. It's used for loading additional kernel modules, usually drivers. When a module is loaded, its "init" function is called by the kernel so that it can hook its functionality into the proper kernel subsystems. My bootit.ko's init function simply reboots the tablet - without properly terminating processes, unmounting filesystems, etc. - so it should only be loaded when no partitions are mounted.
_that said:
I think berndblb meant that insmod injects something into the *currently running* kernel, which it does. It's used for loading additional kernel modules, usually drivers. When a module is loaded, its "init" function is called by the kernel so that it can hook its functionality into the proper kernel subsystems. My bootit.ko's init function simply reboots the tablet - without properly terminating processes, unmounting filesystems, etc. - so it should only be loaded when no partitions are mounted.
Click to expand...
Click to collapse
Nothing like _that to put you in your place....
lj50036 said:
Nothing like _that to put you in your place....
Click to expand...
Click to collapse
I'm trying to get back to a working recovery. Now I get a cycle of TWRP splash screens. This method looks promising because it appears to rebuild all of the partitions. I can use the Vol Down + Power keys to get to the bootloader (us_epad-10.6.1.14.10-20130801 A03. Can I skip to the fastboot steps? I had Crombi-kk running with rom2sd before I broke something trying to upgrade to zombie-x.
Thanks!
awilson77584 said:
I'm trying to get back to a working recovery. Now I get a cycle of TWRP splash screens. This method looks promising because it appears to rebuild all of the partitions. I can use the Vol Down + Power keys to get to the bootloader (us_epad-10.6.1.14.10-20130801 A03. Can I skip to the fastboot steps? I had Crombi-kk running with rom2sd before I broke something trying to upgrade to zombie-x.
Thanks!
Click to expand...
Click to collapse
You can skip all the way down to the command "fastboot erase misc". It should kick you out of twrp cycling...good luck..:fingers-crossed:
LetMeKnow said:
You can skip all the way down to the command "fastboot erase misc". It should kick you out of twrp cycling...good luck..:fingers-crossed:
Click to expand...
Click to collapse
Thx!
Back up and running! Thanks!!!

[HELP] Nexus 5 die, can't enter recovery mode (only Bootloader mode)

Hello,
My phone fell to the floor and since than can't boot.
I see the google logo and then it turning off.
I can't enter recovery mode.
I can enter bootloader mode, tried to re-flash the rom (factory) with -w (wipe) and still can't boot / enter recovery mode.
Any suggestions?
Thanks!
time for a new phone
If the screen is okay, get a nexus 5 with a busted screen and swap internal components.
I have the same problem, but allow me to add some more details:
When trying to go to recovery, i got a dead droid with a red sign on it. See my post on android enthusiasts: /questions/169999/stuck-in-bootloop-and-flash-recovery-doesnt-work-on-nexus-5/170395 (can't post url from my account)
From fast boot, I could flash a recovery (my fastboot is unlocked) but it gave no results: still had the dead droid (tried with twrp, cwm, and stock rom).
After that I gave up trying to get back my data and tried flashing the whole stock rom, but it when bad. Now when trying to flash anything I got errors:
Code:
$ sudo ./fastboot flash cache cache.img
target reported max download size of 1073741824 bytes
erasing 'cache'...
OKAY [ 0.125s]
sending 'cache' (13348 KB)...
OKAY [ 0.630s]
writing 'cache'...
FAILED (remote: flash write failure)
finished. total time: 0.936s
- or -
Code:
$ sudo ./fastboot flash system system.img
target reported max download size of 1073741824 bytes
erasing 'system'...
FAILED (remote: failed to erase partition)
finished. total time: 0.118s
The only good news is I realized I could boot to any arbitrary recovery without flashing it with:
Code:
$ sudo ./fastboot boot recovery.img.twrp
Most functions on recory wouldn't work (it says it can't mount most partitions), but from where I can get an
Code:
adb shell
. I tried various steps but without success so far:
Code:
~ # e2fsck /dev/block/platform/msm_sdcc.1/by-name/recovery
e2fsck 1.41.14 (22-Dec-2010)
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/block/platform/msm_sdcc.1/by-name/recovery
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
Code:
~ # e2fsck /dev/block/platform/msm_sdcc.1/by-name/system
e2fsck 1.41.14 (22-Dec-2010)
system: clean, 1939/65536 files, 254904/262144 blocks
Code:
~ # e2fsck /dev/block/platform/msm_sdcc.1/by-name/cache
e2fsck 1.41.14 (22-Dec-2010)
/dev/block/platform/msm_sdcc.1/by-name/cache: recovering journal
Superblock needs_recovery flag is clear, but journal has data.
Run journal anyway<y>? y
yes
e2fsck: unable to set superblock flags on /dev/block/platform/msm_sdcc.1/by-name/cache
I think I managed to somehow mess up my partition system, and I don't know much how to recover it, anyone have clues or can suggest something ?
You may need to replace the power button on the motherboard. If the phone keeps booting and then restarting when the Google logo appears, the power button might be your culprit. It was for me, and after a trip to my local repair shop, it is as good as new.
Fvolfrine said:
You may need to replace the power button on the motherboard. If the phone keeps booting and then restarting when the Google logo appears, the power button might be your culprit. It was for me, and after a trip to my local repair shop, it is as good as new.
Click to expand...
Click to collapse
The power button works fine on my phone. It's isn't constantly rebooting, but it gets stuck at the booting animation. I can use the power normally in the bootloader and it behaves as expected.
biaib said:
The power button works fine on my phone. It's isn't constantly rebooting, but it gets stuck at the booting animation. I can use the power normally in the bootloader and it behaves as expected.
Click to expand...
Click to collapse
I have the same problem sir.
were you able to solve your issue?
If yes please explain how?
If the phone is stuck at the boot animation, try flashing the oldest Kit Kat ROM from the Google site: https://developers.google.com/android/images
ahiel2 said:
Hello,
My phone fell to the floor and since than can't boot.
I see the google logo and then it turning off.
I can't enter recovery mode.
I can enter bootloader mode, tried to re-flash the rom (factory) with -w (wipe) and still can't boot / enter recovery mode.
Any suggestions?
Thanks!
Click to expand...
Click to collapse
Well I Still am trying to fix that issue since almost 2 years now.....
My guesses are that eMMC is damaged when you thre your phone.
If you do find a solution please do let me know.
Thanks!

Is It Possbile For E5 Play To Be Rooted and Encrypted At the Same Time?

Hello all,
I successfully rooted my phone, so that's good. Part of the instructions are to remove the encryption. Now that it's rooted would it be possible to turn encryption back on? What would happen if I deleted /vendor/etc/fstab.qcom? I'm sure I'd lose my /sdcard/ stuff, but I just did anyway to remove the encryption. (Magisk Manager has settings "Preserve force encryption" and "Preserve AVB 2.0/dm-verity" that I'm not sure what does, but I suspect it's something to do with encryption).
Thanks
Kinda answered my own question. I ran across a menu pick in settings somewhere and clicked on "Encrypt Phone", "note this will take an hour" or something like that. It seems that the phone is encrypted and rooted at this point. What's the old adage, "What could possibly go wrong?", "There's only one way to find out!" TWRP is still on the recovery partition, but can't decrypt the phone. So, probably no backup from TWRP. I wonder what the other drawbacks might be? Hmm.
We have posted TWRP that decrypts so you can ditch my decrypt.zip and you may stay rooted and encrypted as you wish.
Check karthick's thread here:
https://forum.xda-developers.com/moto-e5/development/recovery-twrp-3-2-3-x-moto-e5-plus-t3912189
whodat711 said:
We have posted TWRP that decrypts so you can ditch my decrypt.zip and you may stay rooted and encrypted as you wish.
Check karthick's thread here:
https://forum.xda-developers.com/moto-e5/development/recovery-twrp-3-2-3-x-moto-e5-plus-t3912189
Click to expand...
Click to collapse
Excellent. Thank you!
Well, wait a minute. I put recovery twrp-3.3.1-0-james.img on a Moto-E5 Play (XT1921-2) and it wouldn't boot into recovery. Put previous recovery on and boots into recovery, but of course no decrypt.
This talks about Hanna being updated. https://forum.xda-developers.com/showpost.php?p=79697573&postcount=56
Is twrp-3.3.1-0-james.img supposed to work?
Thanks
Successfully Updated System On Rooted, Encrypted Moto E5 Play
I'm not seeing a lot of information about my particular phone here - Moto E5 Play I bought at Target, XT1921-2. So, I'll post my notes about how I updated it. Note, these are notes - not instructions. Maybe they'll help somebody though. Also note, I'm kinda flying by the seat of my pants here. I really don't know if this is the best/easiest way to update the system. For instance, I'm using a TWRP that doesn't support encryption on this phone. I'm going to try the Hannah TWRP that claims to support encryption at some point, but I haven't yet. All that being said, here's what I did (and it worked).
Code:
# These are notes, not instructions. They assume you know stuff like power
# off before inserting or removing SD card.
# Retrieve un-encrypted SD card from hiding place unknown by adversaries and install in phone.
# Change to Swipe security in case something goes bad.
# Titanium Backup in case something goes bad.
# Copy stuff from /sdcard/ to /external_sd/ in case something goes bad.
# Following this posting:
# https://forum.xda-developers.com/moto-e5/how-to/firmware-moto-e5-xt1944-4-dual-sim-t3820901
# Getting firmware from here:
# https://mirrors.lolinet.com/firmware/moto/james/official/RETUS/
# Download XT1921-2_JAMES_RETUS_8.0.0_OPPS27.91-121-7_cid50_subsidy-DEFAULT_regulatory-DEFAULT_CFC.xml.zip
cd /space/Android/e5play/
mv ~/Downloads/XT1921-2_JAMES_RETUS_8.0.0_OPPS27.91-121-7_cid50_subsidy-DEFAULT_regulatory-DEFAULT_CFC.xml.zip .
mkdir update
cd update/
unzip ../XT1921-2_JAMES_RETUS_8.0.0_OPPS27.91-121-7_cid50_subsidy-DEFAULT_regulatory-DEFAULT_CFC.xml.zip
# These are vim editor commands, which might be helpful to someone well versed
# in viming. The upshot is, massage update/servicefile.xml to look like the
# fastboot commands below.
# :r servicefile.xml
# Addresses from '.'. Always reset the cursor before executing.
# :.,$s/^ *<step operation="\([^"]*\)" var="\([^"]*\)"\/>/fastboot \1 \2
# :.,$s/^ *<step operation="\([^"]*\)" partition="\([^"]*\)"\/>/fastboot \1 \2/
# :.,$s/^ *<step MD5="\([^"]*\)" filename="\([^"]*\)" operation="\([^"]*\)" partition="\([^"]*\)"\/>/fastboot \3 \4 \2/
fastboot oem fb_mode_set
fastboot flash partition gpt.bin
fastboot flash bootloader bootloader.img
fastboot flash modem NON-HLOS.bin
fastboot flash fsg fsg.mbn
fastboot erase modemst1
fastboot erase modemst2
fastboot flash dsp adspso.bin
fastboot flash logo logo.bin
fastboot flash boot boot.img
fastboot flash recovery recovery.img
fastboot flash system system.img_sparsechunk.0
fastboot flash system system.img_sparsechunk.1
fastboot flash system system.img_sparsechunk.2
fastboot flash system system.img_sparsechunk.3
fastboot flash system system.img_sparsechunk.4
fastboot flash vendor vendor.img
fastboot flash oem oem.img
fastboot erase DDR
fastboot oem fb_mode_clear
# Note, also flashed stock recovery. Don't know if this was necessary.
# Now used the phone's system to take the security update.
# Got "bad key" when updating. Seemed to work anyway. Remembered seeing
# this. It seems like these images are unsigned, which isn't a big deal because
# the bootloader is unlocked.
# [[email protected] update]$ fastboot flash boot boot.img
# Sending 'boot' (16384 KB) OKAY [ 0.517s]
# Writing 'boot' (bootloader) Image signed with key bad key
# OKAY [ 0.565s]
# Finished. Total time: 1.085s
# [[email protected] update]$ fastboot flash recovery recovery.img
# Sending 'recovery' (16484 KB) OKAY [ 0.522s]
# Writing 'recovery' (bootloader) Image signed with key bad key
# OKAY [ 1.779s]
# Finished. Total time: 2.303s
# Used Magisk Manager to download Magisk as a zip file. Move the zip file to
# the un-encrypted SD card.
adb shell
cd sdcard/Download/
mv Magisk-v19.3\(19300\).zip /storage/04C7-5787/
cd /space/Android/e5play
fastboot flash recovery twrp_james.img
# Boot into TWRP recovery.
# Swipe to allow modifications.
# Mount Micro SD card (the un-encrypted SD card).
# Use TWRP to install /external_sd/Magisk-v19.
# Reboot system.
# Have root and updated system. Yeah!
# Remove un-encrypted SD card from phone and hide it from adversaries.

Editing system.img inside super.img and flashing our modifications

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:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
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!!***
Code:
./lpmake --metadata-size 65536 --super-name super --metadata-slots 1 --device super:4294967296 --group main:3139354624 --partition system:readonly:1434726400:main --image system=./system.img --partition vendor:readonly:330866688:main --image vendor=./vendor.img --partition product:readonly:1373761536:main --image product=./product.img --sparse --output ./super.new.img
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
good work we got new custom rom!
credit to(for repacking step):
XDA Post: https://forum.xda-developers.com/showpost.php?p=82241115&postcount=70
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'm trying to modify my system.img (/system/build.prop) to include support for multi users. After struggling a lot, I've succeeded following your guide (that's an awesome work btw) to unpack, mount, modify, umount and repack super.img. Then, after flashing the new super.img, nothing changes on the phone. I've tried adding and removing files to the system.img before reflashing, and after flashing, i've verified using adb shell. It seem that the image flashed do not contains my modifications. In other words, I succeed to repack a modified super.img, but flashing the new super.img do not modify the phone itself. Any clues? Can you help me?
Phone is Umidigi A7 Pro 64GB
saga1900 said:
I'm trying to modify my system.img (/system/build.prop) to include support for multi users. After struggling a lot, I've succeeded following your guide (that's an awesome work btw) to unpack, mount, modify, umount and repack super.img. Then, after flashing the new super.img, nothing changes on the phone. I've tried adding and removing files to the system.img before reflashing, and after flashing, i've verified using adb shell. It seem that the image flashed do not contains my modifications. In other words, I succeed to repack a modified super.img, but flashing the new super.img do not modify the phone itself. Any clues? Can you help me?
Phone is Umidigi A7 Pro 64GB
Click to expand...
Click to collapse
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?
Brepro1 said:
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?
Click to expand...
Click to collapse
Hi, thx for your reply!
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.
Vary strange, I don't have an idea, sorry
Brepro1 said:
Vary strange, I don't have an idea, sorry
Click to expand...
Click to collapse
NP, thanks anyway. I'm reading about a few things like disabling vbmeta verity and other things. Also, I did not mentioned, but I've downloaded and modified a stock rom, and my phone is not rooted. If i found anything that worths mention here, I'll update this thread
i cant mounr system.img . Cant you help me
#sudo mount -t ext4 -o loop system.img system
mount: /home/nam/system: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error
NguyenNhutNam said:
i cant mounr system.img . Cant you help me
#sudo mount -t ext4 -o loop system.img system
mount: /home/nam/system: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error
Click to expand...
Click to collapse
what does the command
file path://system.img
show up?
Anyone can help how to repack an unpacked super.img?
Try to delete an app in the product and system.img and post the instructions to repack everything into a super.img again.
My goal is to remove most of the preinstalled Google apps.
Here is the firmware link
UMIDIGI_A9_PRO_128GB_V1-0_20210127
MediaFire is a simple to use free service that lets you put all your photos, documents, music, and video in a single place so you can access them anywhere and share them everywhere.
www.mediafire.com
How do you get this size, from the scatter file super partition size?
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).
After repacking I also get this error, is it normal?
'Invalid sparse file format at header magic'
Brepro1 said:
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!!***
Code:
./lpmake --metadata-size 65536 --super-name super --metadata-slots 1 --device super:4294967296 --group main:3139354624 --partition system:readonly:1434726400:main --image system=./system.img --partition vendor:readonly:330866688:main --image vendor=./vendor.img --partition product:readonly:1373761536:main --image product=./product.img --sparse --output ./super.new.img
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
good work we got new custom rom!
credit to(for repacking step):
XDA Post: https://forum.xda-developers.com/showpost.php?p=82241115&postcount=70
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
Click to expand...
Click to collapse
when I put the command line
./lpmake --metadata-size 65536 --super-name super --metadata-slots 2 --device super: 6836715520 --group main: 6642450432 --partition system: readonly: 5244977152: main --image system =. / system.img --partition odm: readonly: 4349952: main --image odm =. / odm.img --partition product: readonly: 752545792: main --image product =. / product.img --partition vendor: readonly: 640577536: main --image vendor =. / Vendor.img --sparse --output ./super_new.img
it says this: Invalid sparse file format at header magic
why ????
I edited the vendor.img but something strange happens:
$stat -c '%n %s' *
super.img 3758096384
product.img 1596944384
system.img 1128718336
vendor.img 544976896
$../otatools/bin/lpmake --metadata-size 65536 --super-name super --metadata-slots 1 --device super:3758096384 --group main:3270639616 --partition system:readonly:1128718336:main --image system=./system.img --partition vendor:readonly:544976896:main --image vendor=./vendor.img --partition product:readonly:1596944384:main --image product=./product.img --sparse --output ./super.new.img
lpmake I 02-17 12:18:27 2646704 2646704 builder.cpp:1012] [liblp]Partition system will resize from 0 bytes to 1128718336 bytes
lpmake I 02-17 12:18:27 2646704 2646704 builder.cpp:1012] [liblp]Partition vendor will resize from 0 bytes to 544976896 bytes
lpmake I 02-17 12:18:27 2646704 2646704 builder.cpp:1012] [liblp]Partition product will resize from 0 bytes to 1596944384 bytes
Invalid sparse file format at header magic
Invalid sparse file format at header magic
Invalid sparse file format at header magic
BUT....
$stat -c '%n %s' super.new.img
super.new.img 3248851200
which is not divisible by 512!
Shouldn't it be 3758096384 ?
This is for android 10 custom os. Or it will work on all android 10 mobile. Can we modify FRP partition using this.
Me too, sorry
@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.
Here is the link:
https://forum.xda-developers.com/t/script-mount-system-as-read-write-android-10.4240703/
I have same issue as already was mentioned by NguyenNhutNam on Jan-20, i.e.:
In response to
sudo mount -t ext4 -o loop system.img edit
I'm getting this:
wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
And Linux tells me this:
file system.img
system.img: Linux rev 1.0 ext2 filesystem data, UUID=4729639d-b5f2-5cc1-a120-9ac5f788683c (extents) (large files) (huge files)
Of course, I tried:
sudo mount -t ext2 -o loop system.img edit
only to get this:
wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
Any ideas?
Figured out the reason.
Topicstarter confuses people with incorrect instructions.
The code below works great in Ubuntu
Code:
sudo su
mkdir /mnt/dir
mount -t ext4 -o loop,rw ./system.img /mnt/dir
But as soon as I try it directly inside Android I get this error:
Code:
mount: '/dev/block/loop10'->'/mnt/dir': Block device required
I guess this must be some kind of Android limitation...
use busybox mount applet instead of toybox
Brepro1 said:
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
Click to expand...
Click to collapse
None of this is working on the Moto One 5g Ace. All I want to do is get into /product/media/audio/ringtones to delete the crappy ones like I do with EVERY VERSION OF ANDROID and replace them with my own. I can't even open the images up and mod them because of the Read only xx. Please help and give detailed instructions like I'm a 5 year old. Have tried on linux and windows to ZERO success and LeBigMac's script didn't do xxxxx either.
Mod Edit: Post edited.
why don't use magisk native systemless method? just overlay magisk module with desired mods
https://topjohnwu.github.io/Magisk/guides.html#easy-replace
For those who can't mount system image see this twitter conversation by
https://twitter.com/i/web/status/1170404631865778177

Mount system.img from Factory Images

I have downloaded the latest factory image from the google pixel 4a ota page.
Factory Images for Nexus and Pixel Devices | Google Play services | Google for Developers
developers.google.com
When I try to mount system.img for binary extraction, I get the following error.
mount: ../sunfish-rq3a.210805.001.a1/system: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
The image seems not to be an ext4 images, but it's not packed as I can see selinux marks in it.
Which tool do I have to use, to make a raw image or extract the files from it. Or how to get the offset for mounting it?
Maybe this helps...
Code:
$ file system.img
system.img: Android sparse image, version: 1.0, Total of 202187 4096-byte output blocks in 21 input chunks.
It's not a normal filesystem image. The whole super partition has virtual partitions. There might be a way to extract/mount this still...
This might do it. I have done this before, though it wasn't for the system.img in the pixel zip...
How to mount Android 10 vendor image file
I used to extract Android vendor image via following steps: Convert sparse image to raw image: simg2img vendor.img v.img Mount the raw image for copying files: sudo mount v.img somefolder However...
superuser.com
Convert sparse image to raw image: simg2img vendor.img v.img
Mount the raw image for copying files: sudo mount v.img somefolder
a1291762 said:
This might do it. I have done this before, though it wasn't for the system.img in the pixel zip...
How to mount Android 10 vendor image file
I used to extract Android vendor image via following steps: Convert sparse image to raw image: simg2img vendor.img v.img Mount the raw image for copying files: sudo mount v.img somefolder However...
superuser.com
Convert sparse image to raw image: simg2img vendor.img v.img
Mount the raw image for copying files: sudo mount v.img somefolder
Click to expand...
Click to collapse
Thanks a lot. I tried it before, but it failed. But I forgot the loop option.
# mount -t ext4 -o ro,loop v.img somefolder
a1291762 said:
This might do it. I have done this before, though it wasn't for the system.img in the pixel zip...
How to mount Android 10 vendor image file
I used to extract Android vendor image via following steps: Convert sparse image to raw image: simg2img vendor.img v.img Mount the raw image for copying files: sudo mount v.img somefolder However...
superuser.com
Convert sparse image to raw image: simg2img vendor.img v.img
Mount the raw image for copying files: sudo mount v.img somefolder
Click to expand...
Click to collapse
You did this on Windows????
Benjamin B C H said:
You did this on Windows????
Click to expand...
Click to collapse
No, that's Linux commands. Windows has WSL that gives you a Linux shell that might be able to run such commands? I have not used it though because I have a Linux server handy.
a1291762 said:
No, that's Linux commands. Windows has WSL that gives you a Linux shell that might be able to run such commands? I have not used it though because I have a Linux server handy.
Click to expand...
Click to collapse
Ohh...ok .... Thank you so much for your quick response
i am getting this error
Sudo mount -o loop system.img /mnt/system
Errore
Mount: /mnt/system: wrong fa type, bad option, bad superblock on / dev/loop1
Help me
Canna77 said:
i am getting this error
Sudo mount -o loop system.img /mnt/system
Errore
Mount: /mnt/system: wrong fa type, bad option, bad superblock on / dev/loop1
Help me
Click to expand...
Click to collapse
Did you convert the sparse image into a regular image before mounting it?
yes fixed in win10
Mod translation:
i'm trying to get a wifi module to work on a rom, following this guide
5) Now run Ext4 Unpacker which you previously extracted from somewhere, you will see it has a Windows Explorer style interface, easy to use. Now using the button on the top right of the box navigate to the .img file you just extracted earlier and open it. You will see a tree folder structure which are the folders contained in the Android system folder. go inside Vendor then inside modules, select the module you need (in my case the 8192cu.ko file) then right click and select Extract, then decide where to save it.
6) having done this, copy the file onto a USB stick, start the mini pc and connect the stick containing the file to it, then from the file manager transfer the driver file to the mini pc memory
7) you need the terminal emulator, if you don't have it already installed do a search on pc with google
"terminal emulator apk" download it, copy it and install it in your mini pc.
8) start the terminal emulator and go to the folder where you previously copied the driver file, suppose you copied it to /mnt/sdcard, you will have to type cd /mnt/sdcard followed by enter.
9) from the terminal emulator type su followed by enter to become superuser (administrator)
10 type insmod followed by the name of the driver file (in my case insmod 8192cu.ko) and voilà the game is done!
but the insmod command gives me error "exec format failed"
any help?
Hello
You are talking about the new encryption EROFS I updated my huawei p10 EMUI 9.1 to latest version i unlocked the bootloader trying to flash Chinese firmware on it then it bricked no sign of power but my pc recognise it in Fastboot I downloaded a file from xda named p10 revive which includ the flashing firmware. but the partitions are not flashing even if I flash it individually please can some one help and show me how to RW the partition from RO please
Hello after update to latest version of EMUI 9.1 I tried to change my firmware to from VTR_L29 to VTR_AL00 using chimera the phone bricked and never power on again i tried flashing it but no sign of power. My pc recognise it in Fastboot and testpoint is working can some one please help me

Categories

Resources