xfs_repair
filesystemLinux/Unix
The xfs_repair command is one of the most frequently used commands in Linux/Unix-like operating systems. xfs_repair Repair an XFS filesystem
Quick Reference
Command Name:
xfs_repair
Category:
filesystem
Platform:
Linux/Unix
Basic Usage:
xfs_repair [options] [arguments]
Common Use Cases
Syntax
xfs_repair [-nfdPLvVm] [-o options] [-l logdev] [-r rtdev] [-t interval] device
Options
Option | Description |
---|---|
-n |
No-modify mode, check only, don't modify filesystem |
-f |
Force repair even if the filesystem is mounted (dangerous, may cause corruption) |
-d |
Repair dangerously, skip checking some directories |
-P |
Disable prefetching of inode and directory blocks |
-L |
Force log zeroing (overrides -n) |
-v |
Verbose mode, show what's being fixed |
-V |
Print version information |
-m |
Enable additional runtime memory usage measurements |
-o options |
Specify options (e.g., noquota, force_geometry) |
-l logdev |
Specify a device with an external log |
-r rtdev |
Specify a real-time device |
-t interval |
Display progress information at specified intervals (in seconds) |
device |
The special file containing the XFS filesystem (e.g., /dev/sda1) |
Additional Options
The -o
flag can take the following options:
Option | Description |
---|---|
bhash=size |
Size of buffer cache hash table |
ag_stride=blocks |
Allocation group stride length |
phase2=size |
Size of buffer cache for phase 2 |
noquota |
Skip phase 6 (quota checking) |
force_geometry |
Force geometry information even if it's inconsistent |
Examples
How to Use These Examples
The examples below show common ways to use the xfs_repair
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
Check XFS filesystem without making any changes
xfs_repair -n /dev/sda1
Repair an XFS filesystem
xfs_repair /dev/sda1
Force repair even if the filesystem is mounted
xfs_repair -f /dev/sda1
Advanced Examples:
Repair with maximum verbosity
xfs_repair -v /dev/sda1
Repair a filesystem that has an external log device
xfs_repair -l /dev/sdc1 /dev/sda1
Repair a filesystem that has a real-time device
xfs_repair -r /dev/sdd1 /dev/sda1