xfs_check

filesystemLinux/Unix
The xfs_check command is one of the most frequently used commands in Linux/Unix-like operating systems. xfs_check Check XFS filesystem consistency (deprecated in favor of xfs_repair)

Quick Reference

Command Name:

xfs_check

Category:

filesystem

Platform:

Linux/Unix

Basic Usage:

xfs_check [options] [arguments]

Common Use Cases

    Syntax

    xfs_check [-f] [-i ino]... [-b bno]... special

    Options

    Note: xfs_check is deprecated and has been replaced by xfs_repair. It is not installed by default in most recent Linux distributions.

    Option Description
    -f Check for fragmentation
    -i ino Check the specified inode
    -b bno Check the specified block
    special The special file containing the XFS filesystem (e.g., /dev/sdb1)

    Recommended Alternative

    Instead of using xfs_check, it is recommended to use xfs_repair with the -n option:

    Command Description
    xfs_repair -n /dev/device Check filesystem consistency without modifying anything

    Examples

    How to Use These Examples

    The examples below show common ways to use the xfs_check command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    # Check an XFS filesystem (Note: This command is deprecated) xfs_check /dev/sdb1
    # Check specific inodes xfs_check -i 128 /dev/sdb1
    # Check specific blocks xfs_check -b 1024 /dev/sdb1
    # Advanced Examples Advanced
    # Check for fragmentation xfs_check -f /dev/sdb1
    # Check multiple inodes xfs_check -i 128 -i 256 -i 512 /dev/sdb1 # Check multiple blocks xfs_check -b 1024 -b 2048 /dev/sdb1 # Recommended alternative - use xfs_repair in no-modify mode xfs_repair -n /dev/sdb1

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The `xfs_check` command is a legacy tool for checking XFS filesystem consistency. It has been deprecated in favor of `xfs_repair -n`, which provides more thorough checks and better error reporting. Most modern Linux distributions that support XFS do not include xfs_check by default. **Deprecation Status:** 1. **Official Deprecation**: xfs_check has been officially deprecated by the XFS maintainers for many years. 2. **Removal from Distributions**: Many Linux distributions no longer include xfs_check in their default package repositories. 3. **Recommended Alternative**: Users are strongly encouraged to use `xfs_repair -n` instead, which performs the same function but with improved algorithms and error reporting. **Core Functionality:** Despite its deprecated status, understanding xfs_check is useful for historical context and for working with older systems where it might still be available: 1. **Filesystem Verification**: xfs_check performed basic consistency checks on an XFS filesystem, verifying the integrity of metadata structures. 2. **Selective Checking**: Unlike fsck for other filesystems, xfs_check allowed checking specific inodes or blocks, which was useful for targeted debugging. 3. **Fragmentation Analysis**: With the -f option, xfs_check could check for fragmentation levels in the filesystem. **Technical Limitations:** 1. **Performance Issues**: xfs_check could be extremely slow on large filesystems, as it performed exhaustive checks of metadata structures. 2. **Memory Usage**: On very large filesystems, xfs_check could consume excessive amounts of memory. 3. **Limited Repair Capabilities**: Unlike xfs_repair, xfs_check was only a diagnostic tool and could not fix any issues it found. 4. **Crash Risk**: In some cases, running xfs_check on corrupted filesystems could cause system crashes due to how it processed certain metadata structures. **Transition to xfs_repair:** The transition from xfs_check to xfs_repair represents an important evolution in XFS filesystem management: 1. **Improved Algorithms**: xfs_repair uses more efficient algorithms for filesystem verification. 2. **Better Error Reporting**: xfs_repair provides more detailed and actionable error messages. 3. **Repair Capabilities**: While xfs_check was purely diagnostic, xfs_repair can actually fix many types of filesystem corruption when run without the -n flag. 4. **Safety Features**: xfs_repair includes various safeguards to prevent making filesystem corruption worse. **Using xfs_repair Instead:** For all practical purposes, users should use xfs_repair with the -n flag instead of xfs_check: ```bash # Instead of: xfs_check /dev/sda1 # Use: xfs_repair -n /dev/sda1 ``` The -n flag tells xfs_repair to operate in no-modify mode, which makes it function as a checking tool only, similar to the original purpose of xfs_check. **Historical Context:** xfs_check was part of the original suite of XFS tools developed by Silicon Graphics, Inc. (SGI) for their IRIX operating system. When XFS was ported to Linux, xfs_check was included for compatibility and familiarity for IRIX users transitioning to Linux. Over time, as the Linux XFS implementation evolved, xfs_repair was enhanced to provide better functionality, eventually making xfs_check redundant. The maintenance burden of two separate checking tools led to the deprecation of xfs_check in favor of consolidating functionality in xfs_repair. **When You Might Still Encounter xfs_check:** 1. **Legacy Systems**: Older Linux distributions that still include xfs_check. 2. **Custom Environments**: Specialized environments where older XFS tools are still maintained for specific purposes. 3. **Documentation and Scripts**: Old documentation or scripts might still reference xfs_check. **Best Practices:** 1. **Use xfs_repair -n**: Always use xfs_repair -n instead of xfs_check for filesystem verification. 2. **Update Scripts**: If you encounter scripts that use xfs_check, update them to use xfs_repair -n instead. 3. **Unmount First**: Remember that both xfs_check and xfs_repair should only be run on unmounted filesystems to avoid potential data corruption. 4. **Regular Backups**: Regardless of which tool you use, always maintain regular backups of important data before performing any filesystem maintenance. While understanding xfs_check is valuable from a historical perspective and for working with legacy systems, for all practical modern usage, xfs_repair has completely superseded it.

    Related Commands

    These commands are frequently used alongside xfs_check or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the xfs_check command works in different scenarios.

    $ xfs_check
    View All Commands