格式化 mke2fs
&mkfs
- 格式化通常是在新的硬盘上面切割完之后进行的。
- 如果要将旧的扇区格式化成 ext2 格式的话,可以使用该指令。
- 认识格式化
参数
-
-b :可以设定每个 block 的大小,目前支持 1024, 2048, 4096 bytes 三种;
-
-i:多少容量给予一个 inode 呢?
-
-c :检查磁盘错误,仅下达一次 -c 时,会进行快速读取测试;如果下达两次 -c -c的话,会测试读写(read-write),会很慢~
-
-L :后面可以接表头名称 (Label),这个 label 是有用的喔!
-
-j :本来 mke2fs 是 EXT2 ,加上 -j 后,会主动加入 journal 而成为 EXT3。
磁盘格式化mke2fs
- 将上一节内容中(Linux中的磁盘管理——磁盘分区fdisk——Centos7.7)刚建立的/dev/hdb5 格式化成为 ext3 ,且名称为 logical。
mke2fs -j -L "logical" /dev/sdb5
[root@smx ~]# mke2fs -j -L "logical" /dev/sdb5
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=logical
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1245184 inodes, 4980224 blocks
249011 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
152 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
- 查看linux中磁盘的label
[root@smx ~]# e2label /dev/sdb5
logical
- 将 block 改为 2048 ,且 inode 改为 4096
[root@smx ~]# mke2fs -j -L "logical" -b 2048 -i 4096 /dev/sdb5
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=logical
OS type: Linux
块大小=2048 (log=1)
分块大小=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
4980736 inodes, 9960448 blocks
498022 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=547356672
608 block groups
16384 blocks per group, 16384 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816, 1327104,
2048000, 3981312, 5619712
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
磁盘格式化mkfs
- 如果想要格式化其他类型,这里可以直接使用
mkfs
的命令。 - 通过
mkfs.
按两下tab键即跳出很多格式化类型。
[root@smx ~]# mkfs.
mkfs.btrfs mkfs.ext2 mkfs.ext4 mkfs.minix mkfs.vfat
mkfs.cramfs mkfs.ext3 mkfs.fat mkfs.msdos mkfs.xfs
[root@smx ~]# mkfs.ext2 /dev/sdb5
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1245184 inodes, 4980224 blocks
249011 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
152 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: 完成
正在写入inode表: 完成
Writing superblocks and filesystem accounting information: 完成
查看文件类型信息ll
- 查看我们格式化完毕后的分区的文件类型信息
ll
,同时这样的磁盘是不可用的,想要它可用,我们还需要挂载。
[root@smx ~]# ll /dev/sdb5
brw-rw----. 1 root disk 8, 21 8月 12 13:47 /dev/sdb5