1. android 编译完成之后系统镜像会打包成system.img,一般system.img会有不同的格式,根据格式的不同,我们解压需要用不同的工具,在android4.0.4系统中,发现system.img是ext4格式打包的文件,这里做下简单介绍。
2. 涉及工具,ext4_utils,在网上下载,解压后,里面包括:
make_ext4fs mkuserimg.sh simg2img
3. 解包相关命令:
$ file system.img
$ ./simg2img system.img system.img.ext4
$ file ./system.img.ext4
system.img.ext4: Linux rev 1.0 ext4 filesystem data, UUID=57f8f4bc-abf4-655f-bf67-946fc0f9f25b (extents) (large files)
$ sudo mount -t ext4 -o loop system.img.ext4 mountdir/
$ ls mountdir/
app bin build.prop etc fonts framework lib media tts usr vendor xbin
app bin build.prop etc fonts framework lib media tts usr vendor xbin
4. 打包相关命令:
$ sudo make_ext4fs -s -l 512M -a system my_system.img mountdir/
Creating filesystem with parameters:
Size: 536870912
Block size: 4096
Blocks per group: 32768
Inodes per group: 8192
Inode size: 256
Journal blocks: 2048
Label:
Blocks: 131072
Block groups: 4
Reserved block group size: 31
Created filesystem with 1288/32768 inodes and 62649/131072 blocks
Creating filesystem with parameters:
Size: 536870912
Block size: 4096
Blocks per group: 32768
Inodes per group: 8192
Inode size: 256
Journal blocks: 2048
Label:
Blocks: 131072
Block groups: 4
Reserved block group size: 31
Created filesystem with 1288/32768 inodes and 62649/131072 blocks
$ file my_system.img
my_system.img: data
my_system.img: data