[android]system.img文件的打包和解包
16lz
2022-05-25
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 dataAndroid sparse image
2:两种格式的相互转化工具
//sparse image转化成为ext4的raw imgeUsage: simg2img //ext4的raw image to sparse imageUsage: img2simg []
3:system.img文件重新打包的过程
总体思路是将system.img镜像挂载后,然后修改,修改完成为使用make_ext4fs命令进行打包。1:先将system.img文件转化为ext4的raw image file(只要这个格式的system.img可以挂载)2:然后挂载system.imgsudo mount system.img /mnt/system3:然后根据自己的需要,修改/mnt/system目录下的文件4:重新打包sudo make_ext4fs -s -l 3096M new.img /mnt/system5:重新打包后的文件new.img是sparse image格式,所以需要转化成ext4的 raw image sim2img new.img system.img6:至此,修改system.img,重新打包的过程完成
4:recovery.img的打包解包过程
http://rex-shen.net/android-unpackpack-factory-images/
6:boot.img文件的解包
#操作命令mkdir boot && cd bootabooting -x ../boot.img#得到这三个文件 :bootimg.cfg initrd.img zImage#initrd.img文件的解包file initrd.img initrd.img: gzip compressed data, from Unix #可以看到是一个gzip的压缩文件#下面是解压initrd.img文件的命令mkdir initrdcd initrdcat ../initrd.img | gunzip | cpio -vid#解压上面的initrd.img后,可以看到非常多的文件#上面编辑完后,重新打包命令如下cd initrdfind . | cpio --create --format='newc' | gzip > ../myinitd.img#新写打包boot.imgabootimg --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 toolandroid-tools-fastboot Android Fastboot protocol CLI toolandroid-tools-fsutils Android ext4 utilities with sparse supportabootimg Tool to read/write/update android boot images
更多相关文章
- android播放音乐文件代码
- Android得到SD卡文件夹大小以及删除文件夹操作
- Android(安卓)ndk开发之在c文件里打印log
- Android中常用的函数
- Android(安卓)Studio第三十四期 - git企业级应用命令
- Android如何获取asset目录下所有文件的路径
- 通用android studio gradle 文件(电商商家版,两个gradle不同)
- android 学习心得
- NPM 和webpack 的基础使用