mkfs

mkfs功能说明:创建Linux文件系统
mkfs命令用于在指定的设备(或硬盘分区等)上创建格式化并创建文件系统,fdisk和parted等分区工具相当于建房的人,把房子(硬盘),分成几居室(分区),
mkfs就相当于对不同的居室装修(创建文件系统)了,只有装修好的房子(有文件系统)才能入住,分区也是一样,只有格式化创建文件系统(存取数据的机制)后,才能用来存取数据。

参数选项:
-t    指定要创建的文件系统类型
-c    创建文件系统时检查磁盘坏块
-v    显示详细信息



说明:mkfs只是一个前端命令,它通过-t参数指定文件系统类型后会调用相应的命令mkfs.fstype。
因此可以直接使用mkfs.ext4这个命令创建ext4文件系统。

[root@cs6 ~]# ls /sbin/mkfs*
/sbin/mkfs         /sbin/mkfs.ext2  /sbin/mkfs.ext4     /sbin/mkfs.xfs
/sbin/mkfs.cramfs  /sbin/mkfs.ext3  /sbin/mkfs.ext4dev



范例:通过mkfs 命令创建文件系统(-t参数)的例子
 
[root@cs6 ~]# mkfs -t ext4 -v /dev/sdb
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
fs_types for mke2fs.conf resolution: 'ext4', 'default'
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376
 
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
 
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
 



范例:通过mkfs.ext4创建文件系统

[root@cs6 ~]# mkfs.ext4 /dev/sdb
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
....  
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
 
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.



原文地址:https://www.cnblogs.com/l10n/p/14202482.html