$linuxjunkies
>

xfs_repair(8)

Repair a corrupted or inconsistent XFS filesystem.

UbuntuDebianFedoraArch

Synopsis

xfs_repair [OPTION]... DEVICE

Description

xfs_repair scans an XFS filesystem and attempts to repair corrupted metadata, inodes, and directory structures. It can fix issues like bad superblocks, damaged inode allocation trees, and inconsistent link counts. The filesystem must be unmounted before repair is attempted.

The tool operates in phases: first reading the filesystem, then checking consistency, and finally rewriting corrected metadata. Progress output shows which phase is active and can take considerable time on large filesystems.

Common options

FlagWhat it does
-nDry-run mode; shows what would be repaired without making changes
-vVerbose output; prints detailed information about repairs being made
-LClear the log; forces journal reconstruction (use if log is corrupted)
-eStop on the first error instead of continuing to repair
-m MAXMEMLimit memory usage to MAXMEM megabytes during repair
-c BLOCKSIZEOverride the block size detection (rarely needed)
-j THREADSUse THREADS parallel threads for repair operations
-PDisable progress reporting (useful when redirecting output)
-dDisable automatic deferral of metadata checks
-r RTDEVSpecify the realtime device (if filesystem uses separate rt device)

Examples

Preview repairs without modifying filesystem

xfs_repair -n /dev/sda1

Repair a standard XFS filesystem on /dev/sda1 partition

xfs_repair /dev/sda1

Perform repair with verbose output, save results to repair.log

xfs_repair -v /dev/sdb1 2>&1 | tee repair.log

Repair filesystem with corrupted log by forcing log reconstruction

xfs_repair -L /dev/sdc1

Repair using at most 512 MB of memory (useful on low-memory systems)

xfs_repair -m 512 /dev/sda1

Use 4 parallel threads to speed up repair on multi-core systems

xfs_repair -j 4 /dev/sda1

Related commands