Linux分区格式化基础与mkfs工具介绍
硬盘分区建立完毕后,必须执行格式化操作以初始化文件系统。
借助mkfs实用程序可对磁盘分区实施格式化,该工具兼容MBR与GPT两种主流分区表结构。
示例一:将/dev/sdb1分区格式化为ext3类型。
mkfs.ext3 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
系统提示正在写入inode表,并显示操作已完成。
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
示例二:将/dev/sdb5分区格式化为ext4类型。
mkfs -t ext4 /dev/sdb5
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
注意事项说明。
在MBR分区表中,扩展分区无法直接格式化,仅允许对主分区和逻辑分区执行此操作;格式化过程即时生效,无需重启系统,但此时运行df命令无法显示文件系统详情,因为尚未进行挂载步骤。
df -hT /dev/sdb1
Filesystem Type Size Used Avail Use% Mounted on
- - 492M 260K 491M 1% /dev
内容总结。
上述内容介绍了Linux中分区格式化的相关命令,旨在为读者提供实用参考。如有任何疑问或需要进一步探讨,欢迎留言互动,作者将尽快予以回复。