Use this when using or repairing XFS file systems on Linux.
XFS · Linux Storage
XFS is a high-performance journaling Linux file system and the default on RHEL. It scales well for large files and parallel I/O and can grow online, but cannot be shrunk.
1. XFS: scalable, default on RHEL.
2. Grow online, no shrink.
3. Use xfs_repair (unmounted), not fsck.
4. Reflink support.
5. Quotas via mount options.
files → XFS AGs → block device
Context & applicabilityCommon mistakes · platform/version boundaries
- Trying to shrink XFS — not possible; back up and recreate.
- Running
xfs_repairon a mounted file system. - Using
xfs_repair -L(zero the log) too early — mount first to replay the log. - Forgetting that
xfs_growfstakes the mount point, not the device.
Operational reference
Fast context before you go deeper.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- XFS can grow online but not shrink.
- Repair with xfs_repair on an unmounted file system.
- It scales well for large files.
xfs_info <mount>— geometryxfs_repair -n /dev/<dev>— checkxfs_growfs <mount>— grow
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
XFS in operations: grow online, repair offline, never shrink
XFS is the default file system on RHEL and common for large volumes. Day-to-day tasks:
$ xfs_info /srv
meta-data=/dev/mapper/vg0-srv isize=512 agcount=16, agsize=16777216 blks
data = bsize=4096 blocks=268435456, imaxpct=5
log =internal log bsize=4096 blocks=131072, version=2
# lvextend -L +200G vg0/srv && xfs_growfs /srv
# xfs_quota -x -c 'report -h' /srv
Repair
xfs_repair(8) says the file system must be unmounted before repair. -n only scans and reports. A dirty log can only be replayed by the kernel: mount and unmount the file system on a machine with the same CPU architecture, after confirming the hardware is reliable. -L zeroes the log as a last resort, and the manual warns it can lose user files and data.
# umount /srv
# xfs_repair -n /dev/vg0/srv; echo $?
# mount /dev/vg0/srv /srv && umount /srv # replay the log first
# xfs_repair /dev/vg0/srv
| Exit code (xfs_repair) | Meaning |
|---|---|
| 0 | No problems (with -n: no corruption detected) |
| 1 | Corruption detected (-n) or runtime error |
| 2 | Dirty log, repair cannot proceed |
Operational notes
| Topic | Detail |
|---|---|
| Shrinking | Not supported; back up, recreate smaller, restore |
| Forced shutdown | The kernel log shows xfs_do_force_shutdown after metadata I/O errors; fix the device, then repair |
| Backups | xfsdump/xfsrestore, or file-level tools |
| Reflink copies | cp --reflink on file systems created with reflink support |
Always check the block layer (journalctl -k, SMART, multipath) before running a repair. Repairing on failing hardware makes damage worse.
Documented example, not captured output.
Quick reference
XFS on Linux servers: default on RHEL, excellent for large files and parallel I/O, grow-only.
mkfs.xfs -d su=256k,sw=4 -L data /dev/md0
xfs_info /data
xfs_growfs /data
xfs_quota -x -c 'report -h' /data
xfs_fsr /data # online defragmentation
Project quotas (prjquota mount option) limit directory trees, which is useful for per-tenant or per-container limits on a shared filesystem.
ReferenceConfiguration & state2 sections · depth on demand
Commands
mkfs.xfs -L data /dev/sdb1
xfs_info /data
xfs_growfs /data # grow while mounted
xfs_repair -n /dev/sdb1 # check (unmounted)
xfs_fsr /data # defragment
Documented example, not captured output. XFS cannot shrink; to make it smaller, back up, recreate and restore. Good for large files and parallel I/O; default on RHEL.
Useful commands
xfs_info /data
xfs_growfs /data
xfs_repair -n /dev/vg/lv # dry run, unmounted
xfs_db -r -c frag /dev/vg/lv # fragmentation report
xfs_quota -x -c 'report -h' /data
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Linux Storage → XFS. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.kernel.org/block/index.html · confidence 94%