Advanced Package: e2fsprogs / util-linux

mkfs

Create a new filesystem on a partition or device.

Syntax

mkfs -t type device

Description

mkfs formats a partition with a chosen filesystem type (ext4, xfs, vfat, etc.), erasing any existing data. It is usually run right after creating a new partition with fdisk or parted.

Examples

sudo mkfs -t ext4 /dev/sdb1
Format a partition with the ext4 filesystem
sudo mkfs.xfs /dev/sdb1
Format a partition with XFS directly
sudo mkfs.vfat -F32 /dev/sdc1
Format a USB drive as FAT32
This is destructive โ€” double-check the target device name before running.

Applies to

Ubuntu Debian Linux Mint RHEL CentOS / Rocky / AlmaLinux Fedora Arch Linux openSUSE Alpine Linux