mkfs.xfs(8)
Create an XFS filesystem on a device or partition.
Synopsis
mkfs.xfs [OPTIONS] deviceDescription
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
| Flag | What it does |
|---|---|
-f | Force creation without prompting, even if device appears to contain a filesystem |
-L label | Set the filesystem label (up to 12 characters) |
-b size | Set filesystem block size in bytes (512, 1024, 2048, or 4096; default 4096) |
-s size | Set sector size in bytes (512, 2048, or 4096; typically matches device) |
-d size | Specify data section parameters (stripe width, stripe unit, etc.) |
-l size | Set journal size in megabytes or blocks (e.g., 128m or 256b) |
-m crc | Enable CRC checking and other metadata features for data integrity |
-N | Dry run: show what would be done without actually writing to device |
-i size | Set inode size in bytes (256, 512, 1024, 2048, or 4096; default 512) |
-K | Skip zeroing existing filesystem signatures on the device |
Examples
Create a default XFS filesystem on /dev/sda1 with standard settings
sudo mkfs.xfs /dev/sda1Create an XFS filesystem with the label 'mydata' on /dev/sdb1
sudo mkfs.xfs -L mydata /dev/sdb1Force creation of XFS filesystem on NVMe partition without confirmation prompt
sudo mkfs.xfs -f -L storage /dev/nvme0n1p2Create XFS filesystem with CRC enabled and 4KB block size for metadata protection
sudo mkfs.xfs -m crc -b 4096 /dev/sdc1Preview filesystem creation without actually writing (dry run mode)
sudo mkfs.xfs -N -L test /dev/sdd1Create XFS filesystem with 256MB journal and 1024-byte inodes for file metadata
sudo mkfs.xfs -l 256m -i 1024 /dev/sde1