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

发布时间:2019-06-28 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了[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

脚本宝典总结

以上是脚本宝典为你收集整理的[android]system.img文件的打包和解包全部内容,希望文章能够帮你解决[android]system.img文件的打包和解包所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。