• 制作ext4 img的两种方式----转


    原文来自:https://blog.csdn.net/z1026544682/article/details/100137317,有小部分理解修改。

    Ext4有两种镜像方式:一种是裸镜像(raw image)和 稀疏镜像(sparse image)。

    1.1.1  raw image

    1. 描述

    种是raw ext4 image(即raw image),使用file观察:其特点是完整的ext4分区镜像(如果未使用满则使用0进行填充),可以直接使用mount进行挂载,也可以直接烧写,因此比较大。

    好处:升级时设备进行简单的顺序数据写入。通过file可以查看其类型:

    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 

    生成一个128M0roofs.ext4文件:dd if=/dev/zero of=rootfs.ext4 bs=1M count=128

    将新文件格式化为ext4格式:mkfs.ext4 rootfs.ext4

    将文件挂载到mnt目录,注意这里我们要使用mount –o loop的属性,表示我们要把rootfs.ext4当作硬盘分区挂载到mnt:echo 123456 | sudo -S mount -o loop rootfs.ext4 mnt

    rootfs目录下的文件拷贝到mnt目录下:sudo cp rootfs/* mnt/ -rf

    卸载mnt就完成了ext4文件系统制作:sudo umount mnt

    b方式二:使用make_ext4fs(不带-s参数)

    make_ext4fs -l 128M  roofs.ext4 rootfs

    -l 128Mext4文件系统分区大小

    rootfs.ext4:生成ext4文件系统的目标文件

    rootfs:生成ext4文件系统的源目录

    3. 烧写(以mmc为例)

    uboot下使用 mmc write linux下使用 dd,直接烧写。

    1.1.2  simg: sparse image

    1. 描述

    另外一种是sparse ext4 image,它是将raw ext4进行稀疏描述,因此尺寸比较小(制作目录有多少文件就计算多少,没有全零填充)。不能直接挂载。在linux下也不能直接烧写,需要还原为 raw image格式。通过file来查看:

    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选项,即可生成sparse image。

    make_ext4fs -l 128M -s roofs.simg rootfs

    -s:生成ext4S模式镜像(simg

    3. 烧写(linux

    使用simg2imgsimg sparse ext4 image)还原为 raw ext4 image,再像raw image 那样烧写。

    simg2img roofs.simg rootfs.ext4

  • 相关阅读:
    C++头文件保护符和变量的声明定义
    ReactNavtive框架教程(2)
    扩展方法使用
    华为0基础——(练习用)挑7
    HTTP Status 500
    屏蔽DataGridView控件DataError 事件提示的异常信息
    POJ 3630 Phone List Trie题解
    【学习总结】数学-向量叉积
    9.1-9.30推荐文章汇总
    Autolayout环境设置任意个数相等间距排列的按钮的方法
  • 原文地址:https://www.cnblogs.com/mic-chen/p/14030711.html
Copyright © 2020-2023  润新知