1、raw image
(1)描述
一种是raw ext4 image(即raw image),使用file观察:其特点是完整的ext4分区镜像(如果未使用满则使用0进行填充),可以直接使用mount进行挂载,也可以直接烧写因此比较大。
好处:升级时设备进行简单的顺序数据写入。
file rootfs.ext4:
rootfs.ext4: Linux rev 1.0 ext4 filesystem data, UUID=db0ca30c-e2c8-4b9a-b48a-a1620d43aa3a (extents) (large files) (huge files)
(2)制作方法
(a).使用 mkfs.ext4:
mkdir mnt
创建挂载目录
dd if=/dev/zero of=rootfs.ext4 bs=1M count=128
生成一个128M全0的roofs.ext4文件
mkfs.ext4 rootfs.ext4
将新文件格式化为ext4格式
echo 123456 | sudo -S mount -o loop rootfs.ext4 mnt
将文件挂载到mnt目录,注意这里我们要使用mount –o loop的属性,表示我们要把rootfs.ext4当作硬盘分区挂载到mnt
sudo cp rootfs/* mnt/ -rf
将rootfs目录下的文件拷贝到mnt目录下
sudo umount mnt
卸载mnt就完成了ext4文件系统制作
(b).使用make_ext4fs(不带-s参数):
make_ext4fs -l 128M roofs.ext4 rootfs
-l 128M:ext4文件系统分区大小
rootfs.ext4:生成ext4文件系统的目标文件
rootfs:生成ext4文件系统的源目录
(3)烧写(以mmc为例)
uboot下使用 mmc write ,linux下使用 dd,直接烧写。
2、simg: sparse image
(1)描述
另外一种是sparse ext4 image,它是将raw ext4进行稀疏描述,因此尺寸比较小(制作目录有多少文件就计算多少,没有全零填充)。不能直接挂载。在linux下也不能直接烧写,需要还原为 raw image格式。
file alg.ext4:
alg.ext4: Android sparse image, version: 1.0, Total of 262144 4096-byte output blocks in 35 input chunks
(2)制作方法
同样使用make_ext4fs,只需加上-s选项
make_ext4fs -l 128M -s roofs.simg rootfs
-s:生成ext4的S模式镜像(simg)
(3)烧写(linux)
使用simg2img将 simg (sparse ext4 image)还原为 raw ext4 image,再像raw image 那样烧写。
simg2img roofs.simg rootfs.ext4