[android]system.img文件的打包和解包


1:system.img的两种格式

system2_0.img: Linux rev 1.0 ext4 filesystem data, UUID=57f8f4bc-abf4-655f-bf67-946fc0f9f25b (extents) (large files) system1_0.img: Android sparse image, version: 1.0, Total of 393216 4096-byte output blocks in 1765 input chunks. 以上两种格式分别为: ext4 filesystem data Android sparse image

2:两种格式的相互转化工具

//sparse image转化成为ext4的raw imge
Usage: simg2img <sparse_image_files> <raw_image_file> //ext4的raw image to sparse image Usage: img2simg <raw_image_file> <sparse_image_file> [<block_size>]

3:system.img文件重新打包的过程

总体思路是将system.img镜像挂载后,然后修改,修改完成为使用make_ext4fs命令进行打包。

1:先将system.img文件转化为ext4的raw image file(只要这个格式的system.img可以挂载) 2:然后挂载system.img sudo mount system.img /mnt/system  3:然后根据自己的需要,修改/mnt/system目录下的文件 4:重新打包 sudo make_ext4fs -s -l 3096M new.img /mnt/system  5:重新打包后的文件new.img是sparse image格式,所以需要转化成ext4的 raw image sim2img new.img system.img  6:至此,修改system.img,重新打包的过程完成 

4:recovery.img的打包解包过程

http://rex-shen.net/android-unpackpack-factory-images/

6:boot.img文件的解包

#操作命令 mkdir boot && cd boot abooting -x ../boot.img #得到这三个文件 :bootimg.cfg initrd.img zImage  #initrd.img文件的解包 file initrd.img initrd.img: gzip compressed data, from Unix #可以看到是一个gzip的压缩文件  #下面是解压initrd.img文件的命令 mkdir initrd cd initrd cat ../initrd.img | gunzip | cpio -vid #解压上面的initrd.img后,可以看到非常多的文件  #上面编辑完后,重新打包命令如下 cd initrd find . | cpio --create --format='newc' | gzip > ../myinitd.img  #新写打包boot.img abootimg --create myboot.img -f bootimg.cfg -k zImage -r myinitrd.img  #下面的命令可以打印出myboot.img文件中的config信息 abootimg -i myboot.img 

5:Debian系统中包含的Android开发工具

#安装命令 sudo apt-get install android-tools-adb android-tools-fastboot android-tools-fsutils abootimg #每个工具的用途,根据需要安装 android-tools-adb Android Debug Bridge CLI tool android-tools-fastboot Android Fastboot protocol CLI tool android-tools-fsutils Android ext4 utilities with sparse support abootimg Tool to read/write/update android boot images


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM