一、make_ext4fs介绍
make_ext4fs
是一个用于创建 ext4 文件系统的工具。它通常用于在 Android 系统中创建一个镜像文件,该文件可以用于模拟器或设备。以下是 make_ext4fs
的常用参数:
make_ext4fs [ -l <len> ] [ -j <journal size> ] [ -b <block_size> ]
[ -g <blocks per group> ] [ -i <inodes> ] [ -I <inode size> ]
[ -e <flash erase block size> ] [ -o <flash logical block size> ]
[ -L <label> ] [ -f ] [ -a <android mountpoint> ] [ -u ]
[ -S file_contexts ] [ -C fs_config ] [ -T timestamp ]
[ -z | -s ] [ -w ] [ -c ] [ -J ] [ -v ] [ -B <block_list_file> ]
[ -d <base_alloc_file_in> ] [ -D <base_alloc_file_out> ]
<filename> [[<directory>] <target_out_directory>]
- 1、制作ext4文件系统镜像
其中,make_ext4fs <image_file> [ <directory> ]
<image_file>
是要创建的镜像文件的路径和名称,<directory>
是要将其内容添加到镜像中的目录。如果省略,则只会创建一个空的文件系统镜像。 - 2、指定文件系统大小
其中,make_ext4fs -l <len> <image_file> [ <directory> ]
<len>
是要创建的文件系统的大小,单位为字节。 - 3、指定文件系统的块大小,例如
4096
、8192
、16384
等
其中,make_ext4fs -b <block_size> <image_file> [ <directory> ]
<block_size>
是要使用的块大小,单位为字节。 - 4、指定每个块组中的块数
其中,make_ext4fs -g <blocks_per_group> <image_file> [ <directory> ]
<blocks_per_group>
是每个块组中的块数。 - 5、指定文件系统中的inode数目
其中,make_ext4fs -i <inodes> <image_file> [ <directory> ]
<inodes>
是要创建的文件系统中的inode数。 - 6、指定文件系统的 inode 大小,例如
128
、256
、512
等
其中,make_ext4fs -I <inode_size> <image_file> [ <directory> ]
<inode_size>
是要使用的inode 大小,单位为字节。 - 7、指定文件系统标签
其中,make_ext4fs -L <label> <image_file> [ <directory> ]
<label>
是要为文件系统设置的标签。 - 8、指定日志区域的大小
其中,make_ext4fs -j <journal_size> <image_file> [ <directory> ]
<journal_size>
是要使用的日志大小,单位为字节。
二、示例
以下是一个使用 make_ext4fs
创建 ext4 文件系统镜像的示例命令:
make_ext4fs -l 1G -L my_label -I 256 -b 4096 /path/to/output.img /path/to/source/directory
这个命令将创建一个大小为 1GB 的 ext4 文件系统镜像,标签为 “my_label”,inode 大小为 256 字节,块大小为 4096 字节。源目录 /path/to/source/directory
的内容将被添加到文件系统镜像中,输出文件为 /path/to/output.img
。
三、文件系统镜像烧写进分区中
以sd卡为例,执行以下命令:
sudo dd if=root.ext4 of=/dev/sdd bs=1M