xfs_repair
Repair a corrupted XFS filesystem
TLDR
Repair a partition
SYNOPSIS
xfs_repair [ -n ] [ -v ] [ -L ] [ -m process_limit ] [ -t interval ] [ -o sub_options ] [ -f ] device
PARAMETERS
-n
No modify mode: Scans the filesystem and reports the damage found without actually making any changes.
-v
Verbose mode: Provides more detailed output about the repair process.
-L
Log zeroing: Forces zeroing of the filesystem log. Use as a last resort as data loss is possible.
-m process_limit
Limit memory usage: Sets a limit on the number of processes used during repair.
-t interval
Progress interval: Specifies the time interval (in seconds) for displaying progress updates.
-o sub_options
Sub options: Allows specifying specific sub-options for specialized repair tasks. See the man page for details.
-f
Force repair: Forces repair even if the log indicates clean shutdown. Use with extreme caution.
device
The block device representing the XFS filesystem to repair (e.g., /dev/sda1).
DESCRIPTION
xfs_repair is a utility for repairing corrupt or damaged XFS filesystems. It can be used to fix inconsistencies in the filesystem metadata, recover lost data, and generally restore an XFS filesystem to a usable state. It's crucial to unmount the filesystem before running xfs_repair to avoid further damage. In its simplest form, it attempts to automatically repair the filesystem, finding and fixing common errors such as inconsistencies in the free space map, inode tables, and directory structures. For more complex corruption scenarios, xfs_repair offers advanced options to target specific types of problems. Running xfs_repair is a last resort when the filesystem has become unusable due to crashes, hardware failures, or software bugs. Always back up data before using it. It should be performed on an unmounted filesystem, as running it on a mounted filesystem can lead to severe data corruption. Consult the xfs documentation and backups before attempting repairs.
CAVEATS
Running xfs_repair can be risky and may result in data loss if used improperly.
Always back up your data before attempting any repairs. It's crucial that the target filesystem is unmounted before running xfs_repair. If you're unsure about the repair process, consult with an experienced system administrator.
EXIT CODES
The xfs_repair command will return the following exit codes: 0 - successful completion, 1 - error encountered, 2 - usage error.
REALTIME VOLUMES
If the filesystem is a Realtime volume, the realtime device must be specified with the standard -o rtd=
HISTORY
xfs_repair has been part of the xfsprogs package since the early days of the XFS filesystem, which was developed at SGI (Silicon Graphics, Inc.). It has been continuously improved and refined over the years to handle various types of filesystem corruption. Its early versions primarily focused on basic metadata correction, the command was enhanced as XFS gained popularity to address more complex scenarios, including inode corruption, directory structure issues, and free space management.