Monday to Saturday 8:00–19:00, Sunday closedFree courier collection throughout Switzerland · drop-off in Lugano, Zurich and Sant'Antonino

Business

Corrupted XFS: why xfs_repair -L can destroy data

XFS is the default file system of Red Hat, Rocky and Alma Linux, and is widely used in Unraid, in many NAS systems and on large storage servers. When it is damaged, xfs_repair often stops with a message that ends with a suggestion: use -L to destroy the log. It is meant as a last resort, and is regularly used as the first one.

Published 3 min readBy Mirush Murataj

Cover of the RecDati guide: Corrupted XFS: why xfs_repair -L can destroy data
The XFS log holds the last metadata changes; zeroing it discards them.

In short

  • The XFS log holds the last metadata changes; zeroing it discards them.
  • Mount first so the log can replay; then run xfs_repair -n on a copy.
  • Use -L only when the log is unreadable and you accept losing the last changes.

What the log does

XFS writes every metadata change, such as file creations, renames, deletions or extent allocations, first to its log (journal), then to its final location. After a crash, mounting the file system replays the log and brings the metadata back to a consistent state.

xfs_repair refuses to run on a file system with a dirty log, because it cannot know what the log would have changed. Its message: mount the file system to replay the log, or use -L to zero it, which may cause corruption.

The safe order

  1. Image the disk or the volume if it is a single copy of important data, or work on an LVM snapshot or a copy.
  2. Try to mount: mount /dev/sdX1 /mnt. If the log replays, unmount and run xfs_repair -n to see if anything else is wrong.
  3. If the mount fails, read the kernel log (dmesg): Structure needs cleaning, Corruption detected, log mount failed tell you which part is damaged.
  4. Try a read-only mount without log recovery: mount -o ro,norecovery /dev/sdX1 /mnt. The metadata is as it was before the crash; copy the important data off.
  5. Run xfs_repair -n (no modify) on the device or the image and read what it would do.
  6. Only then decide whether xfs_repair without -L, or with -L, is acceptable.

What -L really costs

Zeroing the log throws away every metadata change it contained. Depending on activity, that can be the last few seconds or several minutes before the crash. The consequences:

  • Recently created or renamed files can disappear or come back under their old names.
  • Files being written may point to blocks that also belong to other files; xfs_repair then frees or truncates them.
  • Directories updated in the log can end up in lost+found as numbered entries.

On a quiet file server, the loss is often small. On a database server, a mail server or a VM host writing constantly, it can be serious.

lost+found and nameless files

After a repair, check lost+found at the root of the file system. Files and directories there have lost their names and appear as inode numbers. Their content is usually intact: the file command, the size and the first bytes are often enough to identify them.

Common causes on servers and NAS units

  • Power cuts on systems without a UPS or with write caches without battery protection.
  • Hardware RAID that returned stale data after a disk dropped out.
  • Thin-provisioned storage (LVM thin, SAN, VMware) that ran out of space.
  • Memory errors on systems without ECC.

When the lab helps

  • The underlying disk or array has errors: repairing a file system on failing hardware destroys more.
  • xfs_repair crashed or ran for days.
  • A repair with -L has already been run and important files are missing or in lost+found.

We work on images, can extract files from the log manually, and reconstruct directories from the inodes when the repair moved them.

See server data recovery, NAS data recovery, Unraid: Unmountable: No file system and mdadm array will not assemble: a checklist before any write.

Frequently asked questions

xfs_repair says the log must be replayed but mount fails. Is -L the only option?

Not the first one. Try a read-only mount with norecovery to copy the data, and work on an image before using -L.

How much is lost with -L?

The metadata changes still in the log, usually the last seconds to minutes of activity before the crash.

Can files in lost+found be recovered?

Usually yes: their content is intact, only the names and folders are missing.

Official sources and useful links

Is your data important?

Do not try anything that could make the fault worse. The diagnosis is free and you get a fixed quote before any work starts.

Request a free diagnosis Server data recovery

Device not responding any more? Unplug it and let us take a look.

Get a price