Disk
mkfs
Build a filesystem on a device or partition.
Synopsis
syntax
mkfs [OPTION]... [-t TYPE] DEVICE
Examples
Create ext4 filesystem
sudo mkfs -t ext4 /dev/sdb1
Create labeled XFS filesystem
sudo mkfs.xfs -L mydata /dev/sdc1
Create FAT32 filesystem (for USB drives)
sudo mkfs.vfat /dev/sdb1
Common options
| Flag | Description |
|---|---|
| -t | Filesystem type (ext4, xfs, btrfs, vfat) |
| -L | Volume label |
| -n | Dry run — don't actually create |
About mkfs
The `mkfs` command build a filesystem on a device or partition. Disk commands handle low-level storage operations including partitioning, formatting, filesystem checks, and block device management.
These tools are critical during system installation, storage expansion, data recovery, and performance tuning. Always exercise caution — disk operations can cause data loss if used incorrectly.
The command accepts 3 commonly used flags shown above, though the full set of options is available in the man page (`man mkfs`). The 3 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.
Related commands
More Disk Commands
Other commands in the Disk category