Back to the command reference

mkfs

DisksAdvanced In real Linux

Create a file system (format a partition)

Name: mkfs = make file system

This command needs a real Linux system; you can practise it in real Linux mode.

Full man page

Description

mkfs creates a new file system on a partition, i.e. formats it, erasing whatever was there. It is a front end that calls specific tools such as mkfs.ext4, mkfs.xfs and mkfs.vfat.

Syntax

mkfs [-t TYPE] DEVICE

Common options

-t TYPEType, or use mkfs.ext4, mkfs.vfat directly
mkfs.ext4 / mkfs.xfs / mkfs.vfatThe command for one format, with all its options (mkfs.ext4 -L data /dev/sdb1 sets a label)

Examples

  • $ sudo mkfs.ext4 /dev/sda1

    Format a partition as ext4

    Explain
  • $ sudo mkfs.vfat /dev/sda2

    Format as FAT (common on USB drives)

    Explain

Related