7.6. Checking XFS File System Consistency with xfs_check and xfs_repair

XFS file system consistency checking can be done using the xfs_check command and the dry-run mode of the xfs_repair command. The xfs_repair command is sometimes able to repair file system inconsistencies.

7.6.1. Checking File System Consistency

The file system consistency checking commands for XFS file systems are xfs_check and xfs_repair -n. Unlike fsck, neither xfs_check nor xfs_repair are invoked automatically on system startup. They should be used only if you suspect a file system consistency problem.

Before running xfs_check or xfs_repair -n, the file system to be checked must be unmounted cleanly using normal system administration procedures (the umount command or system shutdown), not as a result of a crash or system reset. If the file system has not been unmounted cleanly, mount it and unmount it cleanly before running xfs_check or xfs_repair -n.

xfs_repair -n checks XFS file system consistency. xfs_repair -n performs a more complete check than xfs_check, but cannot be used to check file systems with extended attributes. Here is the command line for xfs_repair -n:

# xfs_repair -n device

Where device is the device file for a disk partition or logical volume that contains an XFS file system, for example, /dev/xlv/xlv0.

The following example shows output with no consistency problems found:

Phase 1 - find and verify superblock...
Phase 2 - scan file system freespace and inode maps...
        - found root inode chunk
Phase 3 - for each AG...
        - scan (but don't clear) agi unlinked lists...
        - process known inodes and perform inode discovery...
        - process newly discovered inodes...
        - agno = 0
        - agno = 1
        ...
Phase 4 - check for duplicate blocks...
        - setting up duplicate extent list...
        - check for inodes claiming duplicate blocks...
        - agno = 0
        - agno = 1
        ...
No modify flag set, skipping phase 5
Phase 6 - check inode connectivity...
        - traversing file system starting at / ... 
        - traversal finished ... 
        - traversing all unattached subtrees ... 
        - traversals finished ... 
        - moving disconnected inodes to lost+found ... 
Phase 7 - verify link counts...
No modify flag set, skipping file system flush and exiting.

xfs_check also checks XFS file system consistency. It can be used on file systems with Extended Attributes (see the attr(1) man page). (xfs_repair performs only limited checking of Extended Attributes.) Enter the following command line for xfs_check:

# xfs_check device

If no consistency problems were found, xfs_check returns without displaying any messages.

7.6.2. Repairing Inconsistent File Systems

xfs_repair (without the -n option) checks XFS file system consistency and, if problems are detected, corrects them if possible. The file system to be checked and repaired must have been unmounted cleanly using normal system administration procedures (the umount command or system shutdown), not as a result of a crash or system reset. If the file system has not been unmounted cleanly, mount it and unmount it cleanly before running xfs_repair.

When you want xfs_repair to repair any inconsistencies it finds, enter:

# xfs_repair device

Where device is the device file for a disk partition or logical volume that contains an XFS file system, for example /dev/xlv/xlv0. It must not be mounted.

The following example shows the output from running xfs_repair on a clean file system:

Phase 1 - find and verify superblock...
Phase 2 - zero log...
        - scan file system freespace and inode maps...
        - found root inode chunk
Phase 3 - for each AG...
        - scan and clear agi unlinked lists...
        - process known inodes and perform inode discovery...
        - agno = 0
        - agno = 1
        ...
        - process newly discovered inodes...
Phase 4 - check for duplicate blocks...
        - setting up duplicate extent list...
        - clear lost+found (if it exists) ...
        - check for inodes claiming duplicate blocks...
        - agno = 0
        - agno = 1
        ...
Phase 5 - rebuild AG headers and trees...
        - reset superblock counters...
Phase 6 - check inode connectivity...
        - ensuring existence of lost+found directory
        - traversing file system starting at / ... 
        - traversal finished ... 
        - traversing all unattached subtrees ... 
        - traversals finished ... 
        - moving disconnected inodes to lost+found ... 
Phase 7 - verify and correct link counts...
done

For information about using xfs_repair on an inconsistent file system, see the next section.