android开发---解压system.img

android开发---解压system.img 2012-12-28 16:46:17

分类: Android平台

转载:http://blog.chinaunix.net/uid-26009923-id-3454597.html

1. android 编译完成之后会生生一个 system.img,要想解压system.img需要知道system.img是如何打包生成的,这个好像没有工具可以查看system.img的格式,只能一个个的试。
我试了一下unyaffs与unyaffs2都不能解压,最后才发现这个system.img是ext4打包的,用simg2img就ok了!
下载ext4_utils
http://andwise.net/?attachment_id=406
应该有源码的,但这个是编译好的二进制文件,直接拿来用就行。
2. 解压
sun@ubuntu:~/ext4$ ls
ext4_utils.tar.gz  make_ext4fs  simg2img  system.img temp

sun@ubuntu:~/ext4$ file system.img
system.img: data

//生成 ext4格式的img文件
sun@ubuntu:~/ext4$ ./simg2img system.img system.img.ext4

root@yanfa3-desktop:~/ext4# file ./system.img.ext4
./system.img.ext4: Linux rev 1.0 ext4 filesystem data, UUID=57f8f4bc-abf4-655f-bf67-946fc0f9f25b (needs journal recovery) (extents) (large files)

//最后一步挂载,挂载之后就可以像随意修改了
sun@ubuntu:~/ext4$ mkdir ./sys_dir
sun@ubuntu:~/ext4$ mount -t ext4 -o loop system.img.ext4 ./sys_dir/

 

3.打包
sun@ubuntu:~/ext4$ ./make_ext4fs -s -l 512M -a system system_new.img ./sys_dir/
sun@ubuntu:~/ext4$  file ./system_new.img
./system_new.img: data

posted @ 2013-06-01 09:09  云翔世界  阅读(556)  评论(0)    收藏  举报