分区之后,并不能直接使用,需要格式化成特定的文件系统。

格式化(format)是指对磁盘或磁盘中的分区(partition)进行初始化的一种操作,这种操作通常会导致现有的磁盘或分区中所有的文件被清除。

 

 

1. mkfs

该命令用来在特定的分区创建linux文件系统,常见的文件系统有ext2,ext3,vfat等,执行mkfs命令其实是在调用:mkfs.ext3 | mkfs.reiserfs |mkfs.ext2 | mkdosfs | mkfs.msdos | mkfs.vfat ......

 

NAME

       mkfs - build a Linux filesystem

 

SYNOPSIS

       mkfs [options] [-t type] [fs-options] device [size]

 

DESCRIPTION

       This  mkfs  frontend  is  deprecated  in  favour of filesystem specific

       mkfs.<type> utils.

 

       mkfs is used to build a Linux filesystem on a device,  usually  a  hard

       disk  partition.   The  device argument is either the device name (e.g.

       /dev/hda1, /dev/sdb2),  or  a  regular  file  that  shall  contain  the

       filesystem.   The  size argument is the number of blocks to be used for

       the filesystem.

 

       In actuality, mkfs is simply a front-end  for  the  various  filesystem

       builders  (mkfs.fstype) available under Linux.  The filesystem-specific

       builder is searched for via your PATH environment setting only.  Please

       see the filesystem-specific builder manual pages for further details.

 

baoli@ubuntu:~$ mkfs -h

Usage:

mkfs [options] [-t <type>] [fs-options] <device> [<size>]

 

Make a Linux filesystem.

 

Options:

-t, --type=<type>  filesystem type; when unspecified, ext2 is used

     fs-options     parameters for the real filesystem builder

     <device>       path to the device to be used

     <size>         number of blocks to be used on the device

-V, --verbose      explain what is being done;

                      specifying -V more than once will cause a dry-run

-h, --help         display this help

-V, --version      display version

 

将sda1分区格式化为ext4格式:

mfks -t ext4  /dev/sda61

 

 

2. mke2fs

在磁盘分区上创建ext2、ext3、ext4文件系统,默认情况下会创建ext2。

mke2fs命令是专门用于管理ext系列文件系统的一个专门的工具。其还有像mkfs.ext2,mkfs.ext3,mkfs.ext4等衍生的命令,它们的用法mke2fs类似。

 

NAME

       mke2fs - create an ext2/ext3/ext4 filesystem

 

SYNOPSIS

       mke2fs  [ -c | -l filename ] [ -b block-size ] [ -C cluster-size ] [ -d

       root-directory ] [ -D ] [ -g blocks-per-group ] [ -G number-of-groups ]

       [  -i bytes-per-inode ] [ -I inode-size ] [ -j ] [ -J journal-options ]

       [ -N number-of-inodes ] [ -n ] [ -m reserved-blocks-percentage ]  [  -o

       creator-os ] [ -O [^]feature[,...]  ] [ -q ] [ -r fs-revision-level ] [

       -E extended-options ] [ -v ] [ -F ] [ -L  volume-label  ]  [  -M  last-

       mounted-directory ] [ -S ] [ -t fs-type ] [ -T usage-type ] [ -U UUID ]

       [ -V ] [ -e errors-behavior ] [ -z undo_file ] device [ fs-size ]

 

       mke2fs -O journal_dev [ -b block-size ] [ -L volume-label ] [ -n ] [ -q

       ] [ -v ] external-journal [ fs-size ]

 

 

DESCRIPTION

       mke2fs  is used to create an ext2, ext3, or ext4 filesystem, usually in

       a disk partition (or file) named by device.

 

       The file system size is specified by fs-size.  If fs-size does not have

       a  suffix,  it  is interpreted as power-of-two kilobytes, unless the -b

       blocksize option is specified, in which case fs-size is interpreted  as

       the  number  of  blocksize blocks.   If the fs-size is suffixed by 'k',

       'm', 'g', 't' (either upper-case or lower-case), then it is interpreted

       in  power-of-two  kilobytes,  megabytes, gigabytes, terabytes, etc.  If

       fs-size is omitted, mke2fs will create the file  system  based  on  the

       device size.

 

       If mke2fs is run as mkfs.XXX (i.e., mkfs.ext2, mkfs.ext3, or mkfs.ext4)

       the option -t XXX is implied; so mkfs.ext3 will create  a  file  system

       for  use  with  ext3,  mkfs.ext4 will create a file system for use with

       ext4, and so on.

 

       The defaults of the parameters for the newly created filesystem, if not

       overridden   by  the  options  listed  below,  are  controlled  by  the

       /etc/mke2fs.conf configuration file.   See  the  mke2fs.conf(5)  manual

       page for more details.

 

创建ext2 fs:

mke2fs /dev/sdb1

 

 

3. mkxxfs

mkntfs, the same as mkfs.ntfs

mkdosfs

mkinitramfs       

mksquashfs

mkisofs           

mkswap

mklost+found      

mktemp

 

 

4. mkfs.xxx

mkfs.cramfs  mkfs.ext3    mkfs.fat     mkfs.msdos   mkfs.vfat

mkfs.bfs     mkfs.ext2    mkfs.ext4    mkfs.minix   mkfs.ntfs  

 

4.1 mkfs.ext4

$ mkfs.ext4 -h

mkfs.ext4: invalid option -- 'h'

Usage: mkfs.ext4 [-c|-l filename] [-b block-size] [-C cluster-size]

    [-i bytes-per-inode] [-I inode-size] [-J journal-options]

    [-G flex-group-size] [-N number-of-inodes] [-d root-directory]

    [-m reserved-blocks-percentage] [-o creator-os]

    [-g blocks-per-group] [-L volume-label] [-M last-mounted-directory]

    [-O feature[,...]] [-r fs-revision] [-E extended-option[,...]]

    [-t fs-type] [-T usage-type ] [-U UUID] [-e errors_behavior][-z undo_file]

    [-jnqvDFSV] device [blocks-count]

 

4.2 mkfs.vfat mkfs.fat

这个命令是格式化U盘的,vfat是文件系统类型,linux叫vfat, windows下叫FAT32 、 这样格完后,windows linux 默认都都能认识了。

vFAT与FAT向后兼容,但允许文件具有更长的名称, mkfs.vfat并且mkfs.fat是相同的工具。

NAME

       mkfs.fat - create an MS-DOS filesystem under Linux

 

SYNOPSIS

       mkfs.fat [OPTIONS] DEVICE [BLOCK-COUNT]

 

DESCRIPTION

       mkfs.fat is used to create an MS-DOS filesystem under Linux on a device

       (usually a disk partition).  DEVICE is the special  file  corresponding

       to the device (e.g. /dev/sdXX).  BLOCK-COUNT is the number of blocks on

       the device.  If omitted, mkfs.fat automatically determines the filesys‐

       tem size.

 

$ mkfs.vfat --help

mkfs.fat 4.1 (2017-01-24)

Usage: mkfs.fat [-a][-A][-c][-C][-v][-I][-l bad-block-file][-b backup-boot-sector]

       [-m boot-msg-file][-n volume-name][-i volume-id]

       [-s sectors-per-cluster][-S logical-sector-size][-f number-of-FATs]

       [-h hidden-sectors][-F fat-size][-r root-dir-entries][-R reserved-sectors]

       [-M FAT-media-byte][-D drive_number]

       [--invariant]

       [--help]

       /dev/name [blocks]

 

 

Logo

更多推荐