The mkfs command is used to build a Linux file system on a device, which is usually a drive partition. The below table lists some options of the mkfs command and their descriptions.

Option Used To
-v Produce verbose output
-V Produce verbose output including file-system specific command
-t {fstype} Specify type of file system to build
fs-options Pass file system specific options to builder
-c Check device for bad blocks before building
-l {file-name} Read list of bad blocks from file

Syntax

One syntax option of the mkfs command is:

# mkfs [options] {device name}

Another syntax option is:

# mkfs.{file system type} [options] {device name}

Creating a file system on a partition.

fdisk command options

mkfs Command Examples

1. To make the file system:

2. To produce the verbose output:

3. To specify the file system type:

# mkfs -t fstype /dev/sda2 

4. To file system-specific options to be passed to the real file system builder:

5. To check the device for bad blocks before building the file system:

6. To read the bad blocks list from filename:

7. To produce the verbose output: