Error Codes Wiki

Linux XFS Metadata Corruption Repair — What It Means & How to Fix It

Criticalfilesystem error

About Linux XFS Metadata Corruption Repair

Fix XFS file system metadata corruption errors causing mount failures, I/O errors, or forced read-only remounts on Linux. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: XFS metadata corruption occurs when the file system's internal structures become inconsistent. Symptoms include mount failures, 'Structure needs cleaning' messages, or forced read-only remount. XFS is commonly used on enterprise servers, RHEL/CentOS, and as the default for many cloud instances. Unlike ext4, XFS requires the partition to be unmounted before running repair tools. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: Unexpected power loss or hard reset without clean unmount. Failing storage device (bad sectors, controller errors) corrupting data in transit. Kernel bug in the XFS driver causing incorrect metadata writes. Running out of disk space causing incomplete metadata transactions. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Unmount the file system: umount /dev/sdX1 (use a live USB if this is the root partition). Run XFS repair: xfs_repair /dev/sdX1 — this may take a long time for large file systems. If xfs_repair reports 'dirty log', first clear it: xfs_repair -L /dev/sdX1 (warning: this discards uncommitted changes). After repair, mount the file system and check the lost+found directory for recovered files. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

What does xfs_repair -L do?

The -L flag zeroes the XFS journal log. This is necessary when the log is dirty (unwritten transactions) but means those transactions are lost. Only use it after regular xfs_repair fails.

Overview

Fix XFS file system metadata corruption errors causing mount failures, I/O errors, or forced read-only remounts on Linux.

Key Details

  • XFS metadata corruption occurs when the file system's internal structures become inconsistent
  • Symptoms include mount failures, 'Structure needs cleaning' messages, or forced read-only remount
  • XFS is commonly used on enterprise servers, RHEL/CentOS, and as the default for many cloud instances
  • Unlike ext4, XFS requires the partition to be unmounted before running repair tools

Common Causes

  • Unexpected power loss or hard reset without clean unmount
  • Failing storage device (bad sectors, controller errors) corrupting data in transit
  • Kernel bug in the XFS driver causing incorrect metadata writes
  • Running out of disk space causing incomplete metadata transactions

Steps

  1. 1Unmount the file system: umount /dev/sdX1 (use a live USB if this is the root partition)
  2. 2Run XFS repair: xfs_repair /dev/sdX1 — this may take a long time for large file systems
  3. 3If xfs_repair reports 'dirty log', first clear it: xfs_repair -L /dev/sdX1 (warning: this discards uncommitted changes)
  4. 4After repair, mount the file system and check the lost+found directory for recovered files

Tags

xfsmetadatacorruptionxfs_repairfilesystem

Related Items

More in Filesystem Error

Frequently Asked Questions

The -L flag zeroes the XFS journal log. This is necessary when the log is dirty (unwritten transactions) but means those transactions are lost. Only use it after regular xfs_repair fails.