mkfs.ext4 命令 – 对磁盘设备进行EXT4格式化

mkfs.ext4 命令 – 对磁盘设备进行EXT4格式化

/真正好用的Linux命令在线查询手册 / :播放正确发音

《Linux就该这么学》是一本基于最新Linux系统编写的入门必读书籍,内容面向零基础读者,由浅入深渐进式教学,销量保持国内第一,年销售量超过10万余本。点此免费在线阅读。

mkfs.ext4命令来自英文词组make filesystem Ext4的缩写,其功能是对磁盘设备进行EXT4格式化操作。

语法格式:mkfs.ext4 参数 设备名

常用参数:

-b 设置文件数据块大小   -m 设置为管理员保留的文件系统块的百分比
-C++ 格式化前检查分区是否有坏块 -M 设置文件系统的最后挂载目录
-E 设置文件系统扩展选项 -o 覆盖文件系统的“创建者操作系统”字段的默认值
-f 以字节为单位指定片段大小 -O 使用指定的特性创建一个文件系统
-F 强制格式化而不询问 -q 静默执行模式
-g 设置一个块组中的块数 -t 设置要创建的文件系统类型
-i 设置字节和节点的比率 -U 使用指定的UUID创建文件系统
-I 设置每个节点的大小 -V 显示版本信息
-l 读取文件名中的坏块列表    

参考示例

检查指定的磁盘设备并进行格式化操作:

[root@linuxcool ~]# mkfs.ext4 -c /dev/sdb 
mke2fs 1.44.3 (10-July-2018) 
Creating filesystem with 5242880 4k blocks and 1310720 inodes 
Filesystem UUID: 2468ba17-0d37-4900-b67e-5f3a24084fc5 
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000 

Checking for bad blocks (read-only test): 0.00% done, 0:00 elapsed. (0/0/0 errdone 
Allocating group tables: done 
Writing inode tables: done 
Creating journal (32768 blocks): done 
Writing superblocks and filesystem accounting information: done 
 

对指定的磁盘设备进行格式化操作,保留5%容量给管理员:

[root@linuxcool  ~]# mkfs.ext4 -m 5 /dev/sdb
mke2fs 1.44.3 (10-July-2018)
Creating filesystem with 5242880 4k blocks and 1310720 inodes
Filesystem UUID: a3a61300-5195-44c7-be1c-dcf9ba0fbfbe
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 	4096000

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

对指定的磁盘设备进行格式化操作,添加卷标识,并修改块大小:

[root@linuxcool ~]# mkfs.ext4 -L 'LinuxCool' -b 2048 /dev/sdb 
mke2fs 1.44.3 (10-July-2018) 
Creating filesystem with 10485760 2k blocks and 1310720 inodes 
Filesystem UUID: 73ad248c-2a01-49dd-aa46-8770ecbc56fd 
Superblock backups stored on blocks: 
        16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816, 1327104,
        2048000, 3981312, 5619712, 10240000 

Allocating group tables: done 
Writing inode tables: done 
Creating journal (65536 blocks): done 
Writing superblocks and filesystem accounting information: done
 

与该功能相关的Linux命令:

这篇优质的内容由TA贡献而来

刘遄

《Linux就该这么学》书籍作者,RHCA认证架构师,教育学(计算机专业硕士)。