Mke2fsk 命令

光分区了还不算, 还要给分的区建立一种格式, 让磁盘有组织有纪律的存放文件.

mke2fsk就是这样一个格式化分区的工具.

回到之前创建的新分区(并不是让你回去创建分区啊! 很危险的! 看看就好了, 不要真把硬盘搞坏了), 查看一下分区的信息:

  1. # tune2fs -l /dev/sda1
  2. tune2fs 1.35 (28-Feb-2004)
  3. tune2fs: Bad magic number in super-block while trying to open /dev/sda1
  4. Couldn't find valid filesystem superblock.

看吧, 找不到superblock, 话说这个superblock是个什么?


A superblock is a record of the characteristics of a filesystem, including its size, the block size, the empty and the filled blocks and their respective counts, the size and location of the inode tables, the disk block map and usage information, and the size of the block groups.


可以简单地理解为一张大表, 上面记录了各种文件的信息, 系统的信息, 谁放在哪儿了, 哪里还有空位子, 等等等等…

然后我们开始格式化这个分区:

  1. # mke2fs /dev/sda1

说道格式化分区, Gparted实在是一个不可多得的好工具.

  1. # mke2fs -m 0 -b 4096 /dev/sda1
  2. mke2fs 1.35 (28-Feb-2004)
  3. Filesystem label=
  4. OS type: Linux
  5. Block size=4096 (log=2)
  6. Fragment size=4096 (log=2)
  7. 205344 inodes, 70069497 blocks
  8. 0 blocks (0.00%) reserved for the super user
  9. First data block=0
  10. Maximum filesystem blocks=71303168
  11. 2139 block groups
  12. 32768 blocks per group, 32768 fragments per group
  13. 96 inodes per group
  14. Superblock backups stored on blocks:
  15. 32768, 98304, 163840, 229376, 294912, 819200, 884736,
  16. 1605632, 2654208, 4096000, 7962624, 11239424, 20480000,
  17. 23887872
  18. Writing inode tables: done
  19. Writing superblocks and filesystem accounting information:
  20. done
  21. This filesystem will be automatically checked every 32
  22. mounts or 180 days, whichever comes first. Use tune2fs -c
  23. or -i to override.

这里来一点注释:

  • -m 0 设置保留块的百分比为0, 默认是5%. 保留的地方是给root的.
  • -b 4096 设置每一块多少比特, 可用的有1024, 2048 和 4096.

上面的过程, 创建了一个ext2的分区.

你可以用下面的两条命令来创建ext3的分区:

  1. # mkfs.ext3 /dev/sda1
  2. # mke2fs –j /dev/sda1

当然, 还是推荐使用Gparted, 图形化, 更直观.