xfs_repair(8)
Repair a corrupted or inconsistent XFS filesystem.
Synopsis
xfs_repair [OPTION]... DEVICEDescription
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
| Flag | What it does |
|---|---|
-n | Dry-run mode; shows what would be repaired without making changes |
-v | Verbose output; prints detailed information about repairs being made |
-L | Clear the log; forces journal reconstruction (use if log is corrupted) |
-e | Stop on the first error instead of continuing to repair |
-m MAXMEM | Limit memory usage to MAXMEM megabytes during repair |
-c BLOCKSIZE | Override the block size detection (rarely needed) |
-j THREADS | Use THREADS parallel threads for repair operations |
-P | Disable progress reporting (useful when redirecting output) |
-d | Disable automatic deferral of metadata checks |
-r RTDEV | Specify the realtime device (if filesystem uses separate rt device) |
Examples
Preview repairs without modifying filesystem
xfs_repair -n /dev/sda1Repair a standard XFS filesystem on /dev/sda1 partition
xfs_repair /dev/sda1Perform repair with verbose output, save results to repair.log
xfs_repair -v /dev/sdb1 2>&1 | tee repair.logRepair filesystem with corrupted log by forcing log reconstruction
xfs_repair -L /dev/sdc1Repair using at most 512 MB of memory (useful on low-memory systems)
xfs_repair -m 512 /dev/sda1Use 4 parallel threads to speed up repair on multi-core systems
xfs_repair -j 4 /dev/sda1