SUSE Support

Here When You Need Us

Checking some consequences of xfs_repair safely

This document (7018603) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 12

Situation

In case an XFS filesystem cannot be mounted, for example getting an error like

 # mount /dev/sdb /mnt/
mount: mount /dev/sdb on /mnt failed: Structure needs cleaning

and assuming that sdb contains a XFS Filesystem.

Resolution

Before attempting a repair it might be viable to check whether or not issues will be resolved or whether some data might be lost due to the repair.

To get the metadata, assuming /dev/sdb contains a XFS Filesystem, as root run the following command:


 # /usr/sbin/xfs_metadump -aowg /dev/sdb /tmp/dump_xfs_meta

would be invoked. This results in a file /tmp/dump_xfs_meta containing the metadata and no Data Obfuscation.

This file cannot be used yet, but would have to be changed into a restore file with


 # /usr/sbin/xfs_mdrestore /tmp/dump_xfs_meta /tmp/workable_xfs_dump

this new file, /tmp/workable_xfs_dump can be used safely for experiments and test and even be mounted and should exhibit the original error during a mount attempt.

 # mount /tmp/workable_xfs_dump /mnt/
mount: mount /dev/loop0 on /mnt failed: Structure needs cleaning

but after a

 # xfs_repair /tmp/workable_xfs_dump

in this example it can be mounted. And subsequent checked whether files and directories are still in place.

Additional Information

To simulate or force an error in the xfs metadata dump it is possible to invoke

xfs_db -fx /tmp/workable_xfs_dump

then in the shell do

xfs_db> sb
xfs_db> p

and for example change the uuid with

xfs_db> write uuid 12345678
uuid = 20000000-0000-0000-0000-000000bc614e
xfs_db> q

which would then result in an error during mount

 # mount /tmp/workable_xfs_dump /mnt/
mount: mount /dev/loop0 on /mnt failed: Structure needs cleaning

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:7018603
  • Creation Date: 09-Feb-2017
  • Modified Date:03-Mar-2020
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.