TOOL » LINUX » PACKAGE

Mkfs

Partition format

Use /dev/* to format devices. List devices with lsblk.

TIP

Normal files can also be formatted (usually created by fallocate or dd) and then mounted using mount -o loop.

Ext4

Example of creating an ext4 root partition on Linux:

shell
mkfs.ext4 -L root /dev/nvme0n1p3
OptionDescription
-LSet the volume name.

Swap

Example of creating a swap partition on Linux:

shell
mkswap -L swap /dev/nvme0n1p2
OptionDescription
-LSet the volume name.

FAT

Example of creating an UEFI boot partition:

shell
mkfs.fat -F32 -nEFI /dev/nvme0n1p1
OptionDescription
-FSelect the FAT size: 12, 16 or 32.
-nSet the volume name.

NTFS

Example of creating a NTFS partition, usually for compability with Windows OS:

shell
mkfs.ntfs -Q -L data /dev/sdXY
OptionDescription
-f --fast -Q --quickPerform quick (fast) format.
-LSet the volume name.