This is related to this question but as I've made some progress since and run into some rather different issues that would mean I'd essentially have to rewrite it to be a totally different question I've decided to make a new question. As in that question, some device info:
- It's a BLU ADVANCE 4.0
- Board is Mediatek MT6572
- Android version is 4.2.2
- Kernel version is 3.4.5
- I do have root access
I've been trying to take a backup of certain partitions on my phone (boot.img, system.img, recovery.img) but I've run into some problems.
I've found backups online for this model, taken backups with MTK Droid Root and Tools and tried to read directly from /dev/bootimg and /dev/recovery. I've run into a few different issues. There are three main ones and I include them all here as I think they're related. I'm going to start with the one that's consistent across all of these:
The kernel part of my boot.img seems to be way too small (about 18.0KiB - that's not right, is it?) and ends with a bunch of error messages before the GZIP 1F8B that I think marks the start of the ramdisk. Here are the messages:
System halted. Attempting division by 0!... Uncompressing Linux..... decompressor returned an error.. done, booting the kernel... invalid distance too far back... invalid distance code... invalid literal/length code. incorrect header check.. unknown compression method.. invalid window size.invalid block type.. invalid stored block lengths.... too many length or distance symbols. invalid code lengths set.... invalid bit length repeat... invalid literal/lengths set. invalid distances set... incorrect data check.... Out of memory while allocating output buffer.... Out of memory while allocating input buffer. Out of memory while allocating z_stream. Out of memory while allocating workspace.... Not a gzip file. header error.... read error.. uncompression error........
The newlines are from me, I tried to format it as best I could. I'm a little confused about what's going on here as I'm just reading the image - there shouldn't be error messages. Am I just seeing lists of possible errors in the kernel?
I can't extract the contents of the ramdisk in the properly sized kernels (I want to check that the backups worked properly) as in this guide to unpacking boot images When I run this command:
gunzip -c ../your-ramdisk-file | cpio -i
I get the following messages (a whole bunch like the first and finishing with the last two):
cpio: Malformed number (�K����� gzip: ../ramdisk.gz: decompression OK, trailing garbage ignored cpio: premature end of file
and no new file outputted. Note that I can unzip the file by omitting the cpio bit and redirecting the output and it will produce a file containing some recognizable text in a hex editor, so I assume the extraction was successful.
The boot.img read from /dev/bootimg, though it seems to be valid at the start, is way, way too big - I stopped it at 3.0GiB+. For reference the one I found online and the one I generated with MTK Droid Tools and Root are 6.0MiB. By truncating it to 500MiB I was able to find the same kernel structure as in the other ones, though I wasn't sure where the ramdisk ended so couldn't reliably check that.
I suppose my question is basically: what is wrong with my boot.img? Is it valid (despite the errors and inability to extract the ramdisk) and safe to use as a backup?