What does mkfs do, and how do XFS and ext4 differ?
mkfs ("make filesystem") writes a fresh, empty filesystem onto a block device; XFS is RHEL's grow-only default, ext4 is the flexible all-rounder that can also shrink.
A raw LV or partition is just a span of blocks — it has no concept of files until you lay a filesystem on it. mkfs writes that structure (the inode tables, allocation maps, superblock) onto the device, after which it can be mounted:
mkfs -t xfs /dev/vg01/lv01 # = mkfs.xfs ...
mkfs.ext4 /dev/sda2 # the per-type form
Choosing between the two big filesystems:
| XFS | ext4 | |
|---|---|---|
| Role | RHEL default; required by Stratis | Long-standing general-purpose FS |
| Resize | Grow only | Grow and shrink |
| Strength | High throughput on large files / parallel I/O | Mature, predictable, widely supported |
The decision rule: XFS scales beautifully and is the modern default, but its one-way resize means you must size it generously up front. If there's any chance you'll need to reclaim space from a volume later, pick ext4 — it's the only one of the two that can shrink. mkfs is destructive: it discards whatever was on the device, so confirm the path first.
Go deeper:
mkfs(8) man page — building a filesystem on a block device.