首页 > 技巧 > Android刷机包解包打包

作者:ghostry 发布时间:2018-02-04 浏览: 5571

转载注明出处: https://blog.ghostry.cn/technique/852.html
#安装命令
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

system.img有可能有几种格式。

Android sparse image,Linux rev 1.0 ext4 filesystem data,sfs

Ubuntu下有转化工具。

//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>]

ext4文件格式的可以直接mount

mount system.img /mnt/system

挂载后修改完umount
如果原来就是ext4直接用就好,如果原来是sparse就转换一下。
sfs格式的也可以直接挂载

mount -o loop system.sfs

挂载后可以看到里边有一个ext4格式的镜像,再次挂载就好了。

boot.img是文件组合在一起的。使用abootimg工具可以解包打包。
操作命令

mkdir boot  &&  cd boot
abootimg -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 -9 > ../myinitd.img

新写打包boot.img

abootimg --create myboot.img -f bootimg.cfg -k zImage -r myinitrd.img

下面的命令可以打印出myboot.img文件中的config信息

abootimg -i myboot.img 

参考1参考2

标签: ubuntu Android

上一篇: iptables端口映射后php获取客户端ip问题
下一篇: 用docker安装gitlab

添加新评论 »

*
*

欢迎评论!歡迎評論!Comments welcome!komentoj bonvenaj!댓글 오신 것을 환영합니다!
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: :cold: :cryy: :cute: :shy: :sleep: :struggle: :tea: :yahou: