Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

Administer an XFS file system

By updated

Improve this page

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 xfsprogs package (installed by default on RHEL; apt install xfsprogs on 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):

Terminal window
sudo mkfs.xfs -L donnees /dev/sda2
meta-data=/dev/sda2 isize=512 agcount=4, agsize=32768 blks
= crc=1 finobt=1, sparse=1, rmapbt=1
= reflink=1 bigtime=1 inobtcount=1
data = bsize=4096 blocks=131072, imaxpct=25
naming =version 2 bsize=4096 ascii-ci=0, ftype=1

The 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:

Terminal window
sudo mkfs.xfs -L donnees -d su=64k,sw=4 /dev/sda2

Check 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:

Terminal window
sudo xfs_info /mnt/data

The output repeats agcount, bsize and blocks. The label is read or changed with xfs_admin, without unmounting:

Terminal window
sudo xfs_admin -l /dev/sda2 # label = "donnees"
sudo xfs_admin -L data-prod /dev/sda2

Grow 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:

  1. Extend the container (partition with parted, or logical volume with lvextend).
  2. Extend the mounted file system:
Terminal window
sudo xfs_growfs /mnt/data
data blocks changed from 131072 to 262144

The 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:

Terminal window
sudo umount /mnt/data
sudo xfs_repair /dev/sda2

For a diagnosis without changes (check without repairing), add -n:

Terminal window
sudo xfs_repair -n /dev/sda2

If 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.

Terminal window
sudo xfs_repair -L /dev/sda2 # last resort, possible loss

Mount options and quotas

Mount options are added in /etc/fstab (complete configuration in the mount and persistence guide):

OptionEffectFor
noatimedoes not write the access datevery busy volumes
nodev,nosuid,noexechardens the mount/tmp, external disks
uquota / gquota / pquotaenables XFS quotasshared volumes

XFS has built-in quotas per user, group and project. After mounting with uquota, you drive them with xfs_quota:

Terminal window
sudo xfs_quota -x -c 'limit bsoft=50g bhard=60g alice' /mnt/data
sudo xfs_quota -x -c 'report -h' /mnt/data

Troubleshooting

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.

SymptomProbable causeSolution
xfs_repair refuses (dirty log)journal not replayedmount/unmount cleanly, otherwise xfs_repair -L
Impossible to shrink the volumeXFS does not shrinkback up, recreate smaller, restore
XFS errors in dmesgfailing diskjournalctl -k (filter XFS), check smartctl
mkfs.xfs refuses to formatexisting signaturecheck 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.xfs formats; -L sets a label, -d su,sw aligns on RAID.
  • xfs_growfs grows online; XFS does not shrink in practice (experimental shrinking limited to the last allocation group), plan the margin.
  • xfs_repair repairs unmounted; -n diagnoses, -L (erases the journal) is a last resort.
  • xfs_info reads the geometry; xfs_admin changes 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

6 questions
6 min
70% to pass

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

Is this project useful to you?

The guides, courses, quizzes and labs stay free. If you use them regularly, you can contribute to their upkeep and development.

Become a supporting member (new tab) One-time support (new tab) Learn more

Follow the project on LinkedIn