-f
Specifies that the filesystem image to be processed is
stored in a regular file at device (see the mkfs.xfs -d
file option). This might happen if an image copy of a
filesystem has been copied or written into an ordinary
file. This option implies that any external log or
realtime section is also in an ordinary file.
-L
Force Log Zeroing. Forces xfs_repair
to zero the log even
if it is dirty (contains metadata changes). When using
this option the filesystem will likely appear to be
corrupt, and can cause the loss of user files and/or data.
See the DIRTY LOGS
section for more information.
-l
logdev
Specifies the device special file where the filesystem's
external log resides. Only for those filesystems which use
an external log. See the mkfs.xfs -l
option, and refer to
xfs(5) for a detailed description of the XFS log.
-r
rtdev
Specifies the device special file where the filesystem's
realtime section resides. Only for those filesystems which
use a realtime section. See the mkfs.xfs -r
option, and
refer to xfs(5) for a detailed description of the XFS
realtime section.
-n
No modify mode. Specifies that xfs_repair
should not
modify the filesystem but should only scan the filesystem
and indicate what repairs would have been made. This
option cannot be used together with -e
.
-P
Disable prefetching of inode and directory blocks. Use
this option if you find xfs_repair
gets stuck and stops
proceeding. Interrupting a stuck xfs_repair
is safe.
-m
maxmem
Specifies the approximate maximum amount of memory, in
megabytes, to use for xfs_repair
. xfs_repair
has its own
internal block cache which will scale out up to the lesser
of the process's virtual address limit or about 75% of the
system's physical RAM. This option overrides these
limits.
NOTE:
These memory limits are only approximate and may use
more than the specified limit.
-c
subopt=
value
Change filesystem parameters. Refer to xfs_admin(8) for
information on changing filesystem parameters.
-o
subopt[=
value]
Override what the program might conclude about the
filesystem if left to its own devices.
The suboptions supported are:
bhash=
bhashsize
overrides the default buffer cache hash size.
The total number of buffer cache entries are
limited to 8 times this amount. The default size
is set to use up the remainder of 75% of the
system's physical RAM size.
ag_stride=
ags_per_concat_unit
This creates additional processing threads to
parallel process AGs that span multiple concat
units. This can significantly reduce repair
times on concat based filesystems.
force_geometry
Check the filesystem even if geometry
information could not be validated. Geometry
information can not be validated if only a
single allocation group exists and thus we do
not have a backup superblock available, or if
there are two allocation groups and the two
superblocks do not agree on the filesystem
geometry. Only use this option if you validated
the geometry yourself and know what you are
doing. If In doubt run in no modify mode first.
noquota
Don't validate quota counters at all.
Quotacheck will be run during the next mount to
recalculate all values.
-t interval
Modify reporting interval, specified in seconds. During
long runs xfs_repair
outputs its progress every 15
minutes. Reporting is only activated when ag_stride is
enabled.
-v
Verbose output. May be specified multiple times to
increase verbosity.
-d
Repair dangerously. Allow xfs_repair
to repair an XFS
filesystem mounted read only. This is typically done on a
root filesystem from single user mode, immediately
followed by a reboot.
-e
If any metadata corruption was repaired, the status
returned is 4 instead of the usual 0. This option cannot
be used together with -n
.
-V
Prints the version number and exits.
Checks Performed
Inconsistencies corrected include the following:
1. Inode and inode blockmap (addressing) checks: bad magic
number in inode, bad magic numbers in inode blockmap
blocks, extents out of order, incorrect number of records
in inode blockmap blocks, blocks claimed that are not in a
legal data area of the filesystem, blocks that are claimed
by more than one inode.
2. Inode allocation map checks: bad magic number in inode map
blocks, inode state as indicated by map (free or in-use)
inconsistent with state indicated by the inode, inodes
referenced by the filesystem that do not appear in the
inode allocation map, inode allocation map referencing
blocks that do not appear to contain inodes.
3. Size checks: number of blocks claimed by inode
inconsistent with inode size, directory size not block
aligned, inode size not consistent with inode format.
4. Directory checks: bad magic numbers in directory blocks,
incorrect number of entries in a directory block, bad
freespace information in a directory leaf block, entry
pointing to an unallocated (free) or out of range inode,
overlapping entries, missing or incorrect dot and dotdot
entries, entries out of hashvalue order, incorrect
internal directory pointers, directory type not consistent
with inode format and size.
5. Pathname checks: files or directories not referenced by a
pathname starting from the filesystem root, illegal
pathname components.
6. Link count checks: link counts that do not agree with the
number of directory references to the inode.
7. Freemap checks: blocks claimed free by the freemap but
also claimed by an inode, blocks unclaimed by any inode
but not appearing in the freemap.
8. Super Block checks: total free block and/or free i-node
count incorrect, filesystem geometry inconsistent,
secondary and primary superblocks contradictory.
Orphaned files and directories (allocated, in-use but
unreferenced) are reconnected by placing them in the lost+found
directory. The name assigned is the inode number.
Disk Errors
xfs_repair
aborts on most disk I/O errors. Therefore, if you are
trying to repair a filesystem that was damaged due to a disk
drive failure, steps should be taken to ensure that all blocks in
the filesystem are readable and writable before attempting to use
xfs_repair
to repair the filesystem. A possible method is using
dd
(8) to copy the data onto a good disk.
lost+found
The directory lost+found does not have to already exist in the
filesystem being repaired. If the directory does not exist, it
is automatically created if required. If it already exists, it
will be checked for consistency and if valid will be used for
additional orphaned files. Invalid lost+found directories are
removed and recreated. Existing files in a valid lost+found are
not removed or renamed.
Corrupted Superblocks
XFS has both primary and secondary superblocks. xfs_repair
uses
information in the primary superblock to automatically find and
validate the primary superblock against the secondary superblocks
before proceeding. Should the primary be too corrupted to be
useful in locating the secondary superblocks, the program scans
the filesystem until it finds and validates some secondary
superblocks. At that point, it generates a primary superblock.
Quotas
If quotas are in use, it is possible that xfs_repair
will clear
some or all of the filesystem quota information. If so, the
program issues a warning just before it terminates. If all quota
information is lost, quotas are disabled and the program issues a
warning to that effect.
Note that xfs_repair
does not check the validity of quota limits.
It is recommended that you check the quota limit information
manually after xfs_repair
. Also, space usage information is
automatically regenerated the next time the filesystem is mounted
with quotas turned on, so the next quota mount of the filesystem
may take some time.