Factory update.img contains encrypted images, therefore it is needed to flash update.img to device and dump them (unencrypted).
AFPTool.exe -unpack update.img update
You will get boot.img, kernel.img, system.img, etc. in update/Image folder.
AFPTool.exe -pack update update.img
First install cramfsprogs & fusecram
sudo apt-get install cramfsprogs fusecram
#!/bin/sh echo "unpacking..." mkdir $1 sudo mount -t cramfs -o loop $1.img $1 tar cvzf $1.tgz $1 sudo umount $1 tar xzvf $1.tgz echo "done"
Usage:
./unpack.sh update
mkcramfs system system.img
You can use same steps to unpack boot and recovery images, but it is needed to add CRC at the end of both images.
Pack boot/recovery
mkfs.cramfs -n v1.01 boot boot.img
Add CRC
rkcrc file.img file-crc.img
This howto is based on work of xaueious.