FORUMS
Remove All Ads from XDA
H10 Turbo

[Tool] SparseConverter v1.0.1

46 posts
Thanks Meter: 88
 
By tal.aloni, Member on 13th May 2014, 07:55 AM
Post Reply Email Thread
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.
Attached Files
File Type: zip SparseConverter_1.0.1.zip - [Click for QR Code] (8.9 KB, 9538 views)
File Type: zip SparseConverter_1.0.1_Source.zip - [Click for QR Code] (19.3 KB, 2910 views)
The Following 20 Users Say Thank You to tal.aloni For This Useful Post: [ View ] Gift tal.aloni Ad-Free
 
 
3rd January 2015, 10:32 AM |#2  
Senior Member
Flag Levice
Thanks Meter: 32
 
More
How can i flash system.img when is too large. i have compressed it using this tool, now how to flash?
3rd January 2015, 11:01 AM |#3  
OP Member
Thanks Meter: 88
 
More
Everything is explained in the original post, You need to use fastboot.exe which is part of the ADT bundle (Android Development Tools).
6th January 2015, 06:47 PM |#4  
Senior Member
Flag Levice
Thanks Meter: 32
 
More
Quote:
Originally Posted by tal.aloni

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

fastboot flash system system.img_sparsechunk1 ?
Not working for me. :/

It will be downloaded to device, but not flashed.
6th January 2015, 08:39 PM |#5  
OP Member
Thanks Meter: 88
 
More
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?
10th January 2015, 03:25 PM |#6  
Senior Member
Flag Levice
Thanks Meter: 32
 
More
Quote:
Originally Posted by tal.aloni

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?

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.
10th January 2015, 03:58 PM |#7  
OP Member
Thanks Meter: 88
 
More
Sorry, I'm not familiar with this error.
10th January 2015, 07:24 PM |#8  
Senior Member
Flag Levice
Thanks Meter: 32
 
More
Quote:
Originally Posted by tal.aloni

Sorry, I'm not familiar with this error.

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.
13th January 2015, 03:32 AM |#9  
Member
Thanks Meter: 37
 
More
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:
matt@Chell:~$ sudo mount -t ext4 -o loop /home/matt/userdata.img /home/matt/ext4
[sudo] password for matt:
matt@Chell:~$ sudo su
root@Chell:/home/matt# cd ext4
root@Chell:/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
13th January 2015, 09:01 AM |#10  
OP Member
Thanks Meter: 88
 
More
Hi Matt,
Quote:

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.

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).
1st February 2015, 07:18 PM |#11  
hazard666's Avatar
Senior Member
Ohio
Thanks Meter: 23
 
More
Quote:
Originally Posted by tal.aloni

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.

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!
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes