$linuxjunkies
>

mkfs.xfs(8)

Create an XFS filesystem on a device or partition.

UbuntuDebianFedoraArch

Synopsis

mkfs.xfs [OPTIONS] device

Description

mkfs.xfs constructs an XFS filesystem on a specified device, partition, or file. XFS is a high-performance 64-bit journaling filesystem designed for scalability and speed, commonly used on high-capacity storage and enterprise systems.

The device argument is typically a block device like /dev/sda1, /dev/nvme0n1p2, or a loopback device. All existing data on the device will be destroyed. The filesystem must be mounted to be used after creation.

Common options

FlagWhat it does
-fForce creation without prompting, even if device appears to contain a filesystem
-L labelSet the filesystem label (up to 12 characters)
-b sizeSet filesystem block size in bytes (512, 1024, 2048, or 4096; default 4096)
-s sizeSet sector size in bytes (512, 2048, or 4096; typically matches device)
-d sizeSpecify data section parameters (stripe width, stripe unit, etc.)
-l sizeSet journal size in megabytes or blocks (e.g., 128m or 256b)
-m crcEnable CRC checking and other metadata features for data integrity
-NDry run: show what would be done without actually writing to device
-i sizeSet inode size in bytes (256, 512, 1024, 2048, or 4096; default 512)
-KSkip zeroing existing filesystem signatures on the device

Examples

Create a default XFS filesystem on /dev/sda1 with standard settings

sudo mkfs.xfs /dev/sda1

Create an XFS filesystem with the label 'mydata' on /dev/sdb1

sudo mkfs.xfs -L mydata /dev/sdb1

Force creation of XFS filesystem on NVMe partition without confirmation prompt

sudo mkfs.xfs -f -L storage /dev/nvme0n1p2

Create XFS filesystem with CRC enabled and 4KB block size for metadata protection

sudo mkfs.xfs -m crc -b 4096 /dev/sdc1

Preview filesystem creation without actually writing (dry run mode)

sudo mkfs.xfs -N -L test /dev/sdd1

Create XFS filesystem with 256MB journal and 1024-byte inodes for file metadata

sudo mkfs.xfs -l 256m -i 1024 /dev/sde1

Related commands