XFS is the default file system of RHEL, AlmaLinux and Rocky: built for large volumes and concurrent access. This guide shows how to format with mkfs.xfs, read the parameters with xfs_info, grow online with xfs_growfs and repair with xfs_repair. For beginner to intermediate administrators. Outputs captured on an AlmaLinux test disk. The choice between XFS, ext4 and Btrfs is covered in the dedicated decision guide.
What you will learn
- Format a volume as XFS with
mkfs.xfs - Read the parameters with
xfs_info - Grow online with
xfs_growfs(and why no shrinking) - Check and repair with
xfs_repair
Prerequisites
- A volume to format (partition or LVM logical volume)
- The
xfsprogspackage (installed by default on RHEL;apt install xfsprogson Debian/Ubuntu)
Why XFS
XFS was designed by Silicon Graphics to handle very large volumes with high throughput. Available on Linux since the early 2000s, it is the default of the Red Hat family. Its architecture in allocation groups allows several write operations in parallel, which makes it excellent for databases, multimedia and busy file servers.
Two limits to know before choosing XFS:
- No shrinking in practice: an XFS volume can only grow. Plan the margin at creation time.
- No native snapshots or compression: for that, look at Btrfs or the LVM layer.
Create an XFS file system
The mkfs.xfs command formats the volume. With a label (-L):
sudo mkfs.xfs -L donnees /dev/sda2meta-data=/dev/sda2 isize=512 agcount=4, agsize=32768 blks = crc=1 finobt=1, sparse=1, rmapbt=1 = reflink=1 bigtime=1 inobtcount=1data = bsize=4096 blocks=131072, imaxpct=25naming =version 2 bsize=4096 ascii-ci=0, ftype=1The output summarises the geometry: 4 allocation groups (agcount=4), checksums on metadata (crc=1, the modern default) and a block size of 4096 bytes. For a volume on RAID, align with -d su=<stripe>,sw=<disks> to optimise writes:
sudo mkfs.xfs -L donnees -d su=64k,sw=4 /dev/sda2Check the result
xfs_info shows the geometry of a mounted XFS volume. It is the check after formatting, and the command to read before growing:
sudo xfs_info /mnt/dataThe output repeats agcount, bsize and blocks. The label is read or changed with xfs_admin, without unmounting:
sudo xfs_admin -l /dev/sda2 # label = "donnees"sudo xfs_admin -L data-prod /dev/sda2Grow online with xfs_growfs
It is XFS's great strength in production: growing without unmounting. The operation is always done in two steps, container first, file system next:
- Extend the container (partition with
parted, or logical volume withlvextend). - Extend the mounted file system:
sudo xfs_growfs /mnt/datadata blocks changed from 131072 to 262144The line confirms the doubling of the number of blocks. No need to give a size: XFS takes all the available space in its container.
Check and repair with xfs_repair
XFS is not checked at boot (passno column at 0 in /etc/fstab). In case of an incident, the dedicated tool is xfs_repair, and the volume must be unmounted:
sudo umount /mnt/datasudo xfs_repair /dev/sda2For a diagnosis without changes (check without repairing), add -n:
sudo xfs_repair -n /dev/sda2If the volume refuses to mount because of a corrupted journal and xfs_repair asks for it, -L erases the journal. It is a last resort: it can lose the most recent writes.
sudo xfs_repair -L /dev/sda2 # last resort, possible lossMount options and quotas
Mount options are added in /etc/fstab (complete configuration in the mount and persistence guide):
| Option | Effect | For |
|---|---|---|
noatime | does not write the access date | very busy volumes |
nodev,nosuid,noexec | hardens the mount | /tmp, external disks |
uquota / gquota / pquota | enables XFS quotas | shared volumes |
XFS has built-in quotas per user, group and project. After mounting with uquota, you drive them with xfs_quota:
sudo xfs_quota -x -c 'limit bsoft=50g bhard=60g alice' /mnt/datasudo xfs_quota -x -c 'report -h' /mnt/dataTroubleshooting
XFS incidents are recognised by the tool that refuses to act: xfs_repair facing an unreplayed journal, mkfs.xfs facing an existing signature, or the kernel logging errors in dmesg. The table starts from that message.
| Symptom | Probable cause | Solution |
|---|---|---|
xfs_repair refuses (dirty log) | journal not replayed | mount/unmount cleanly, otherwise xfs_repair -L |
| Impossible to shrink the volume | XFS does not shrink | back up, recreate smaller, restore |
XFS errors in dmesg | failing disk | journalctl -k (filter XFS), check smartctl |
mkfs.xfs refuses to format | existing signature | check the target, then -f if certain |
Put it into practice
Formatting is the founding action of the whole storage chain: best to do it once for real. The lab has you create an XFS file system with mkfs.xfs on a prepared partition, give it a label, then mount it and prove the result through the type, the label and the active mount.
Key points
- XFS is the RHEL default: high performance, large volumes, concurrent access.
mkfs.xfsformats;-Lsets a label,-d su,swaligns on RAID.xfs_growfsgrows online; XFS does not shrink in practice (experimental shrinking limited to the last allocation group), plan the margin.xfs_repairrepairs unmounted;-ndiagnoses,-L(erases the journal) is a last resort.xfs_inforeads the geometry;xfs_adminchanges the label without unmounting.- Built-in quotas with
xfs_quota; no snapshots or compression (see Btrfs).
Knowledge check
Check that the essentials of this guide are acquired. The questions only cover what has just been explained here.
Knowledge check
Check what you have learned with this interactive quiz
How it works
- The timer starts when you click Start
- Multiple choice, true/false and short answer questions
- You can move between questions
- Detailed results are shown at the end
Starts the quiz and the timer
Review
(0/0)Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Mount a file system and make it persistent
A new full quiz with random questions
Work again only on the questions you missed