Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
sparseChunks to image Convertor for motorola images
#SparseChunks to image Convertor for motorola images by Erfan Abdi
#special thanks to superR for header removal script
#make sure you have only one image with sparse chunks (system or oem)
echo "Converting all SparseChunks to Raw Image"
./simg2img *chunk* system.img.raw
echo "Removing Moto Header"
offset=$(LANG=C grep -aobP -m1 '\x53\xEF' system.img.raw | head -1 | gawk '{print $1 - 1080}')
dd if=system.img.raw of=system_moto.img ibs=$offset skip=1 2>&1
echo "Removing Raw Image"
rm -rf system.img.raw
echo "Removing Moto Footer"
head -c $(( 4*1024*-1 )) system_moto.img > system.img
echo "Removing moto Image"
rm -rf system_moto.img
echo "system.img is ready"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment