1

I want to change the recovery image from ODIN package for Samsung P601. I've unpacked the archive and got recovery.img. Next I've tried to do simg2img recovery.img recovery.raw.img, but it says:

Invalid sparse file format at header magi Failed to read sparse file

I think that means that it should not be converted. I've tried to mount it, but the FS seems to be not ext4.

So, the question is - how to mount recovery.img, change files there and save it back? I'm using OS X and Windows (with cygwin).

1

You can use unmkbootimg from this thread on XDA Developers.

$ unmkbootimg recovery.img

This should give you two files: initramfs.cpio.gz and zImage (the kernel image). To extract initramfs.cpio.gz use this command:

$ mkdir ramdisk && cd ramdisk
$ gunzip -c ../initramfs.cpio.gz | cpio -i

Check this post for more detailed information.

EDIT: I just realized I only answered half of the question. To re-pack the image after making changes to the extracted files, use the command that unmkbookimg gave you, e.g.

mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x40000000 --cmdline 'console=ttyS0,115200 rw init=/init loglevel=8' -o new_boot.img

According to the article, use this command to create the new initramfs.cpio.gz file (untested):

find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
0

Recovery isn't a sparse image (which is an Ext4) so you cannot do that, neither mount it. It's a boot image for which you can use mkbootimg.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.