Checking and Repairing an XFS File System

Note:

If you have an Oracle Linux Premier Support account and observe a problem mounting an XFS file system, send a copy of the /var/log/messages file to Oracle Support and wait for advice.

If you can't mount an XFS file system, you can use the xfs_repair -n command to check its consistency. Typically, you would only run this command on the device file of an unmounted file system that you believe has a problem. The xfs_repair -n command displays output to indicates changes that would be made to the file system in the case where it would need to complete a repair operation, but doesn't modify the file system directly.

If you can mount the file system and you don't have a suitable backup, you can use the xfsdump command to back up the existing file system data. However, note that the command might fail if the file system's metadata has become corrupted.

You can use the xfs_repair command to repair an XFS file system that's specified by its device file. The command replays the journal log to fix any inconsistencies that might have resulted from the file system not being cleanly unmounted. Unless the file system has an inconsistency, you typically don't need to use the follwoing command, as the journal is replayed every time that you mount an XFS file system.

sudo xfs_repair device

If the journal log has become corrupted, you can reset the log by specifying the -L option to xfs_repair.

Attention:

Resetting the log can leave the file system in an inconsistent state, resulting in data loss and data corruption. Unless you're experienced with debugging and repairing XFS file systems by using the xfs_db command, we recommend that you instead re-create the file system and restore its contents from a backup.

If you can't mount the file system or you don't have a suitable backup, running the xfs_repair command is the only viable option, unless you're experienced in using the xfs_db command.

xfs_db provides an internal command set for debuggin and repairing an XFS file system manually. The commands enable you to perform scans on the file system, and navigate and display its data structures. If you specify the -x option to enable expert mode, you can modify the data structures.

sudo xfs_db [-x] device

For more information, see the xfs_db(8) and xfs_repair(8) manual pages, and run the help command within xfs_db.