From: Amit Shah <amit@infradead.org>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: Fixing a corrupted file system
Date: Thu, 02 Apr 2026 20:18:37 +0200 [thread overview]
Message-ID: <cc26312ada6ced3283bf36d249487ff7604604f9.camel@infradead.org> (raw)
In-Reply-To: <fc202c52-cb3e-40b2-a80a-6ffda886f76b@suse.com>
Hello Qu,
On Thu, 2026-04-02 at 07:51 +1030, Qu Wenruo wrote:
>
>
> 在 2026/4/2 02:28, Amit Shah 写道:
> > Hello folks,
> >
> > I had a msata drive that started showing signs of failure - error
> > reading sectors. I had a single LUKS partition on it (for
> > encryption)
> > with btrfs as the file system taking up the entire space (1 TB).
> >
> > I got all the raw data from the drive via ddrescue, and have dumped
> > it
> > into a second drive. However, it looks like before I noticed the
> > disk
> > errors, btrfs tried correcting them based on the erroneous reads on
> > the
> > first disk, causing those errors to propagate on the recovered
> > copy:
>
> Nope, btrfs will only try extra mirrors, but in your case your
> metadata
> doesn't even have extra mirrors.
> Which is not common, as the default btrfs mkfs profiles will go DUP
> for
> metadata.
Hm, looks like the functionality for auto-enabling metadata DUP only
landed in 5.15, and perhaps my install was from before that? I didn't
go out of my way to select non-default entries.
> So you only have one chance and lost that chance.
[...]
> > 1. Can I do anything to fix the metadata for this filesystem, and
> > have
> > it mount, recognize and recover the data on there?
>
> Not really. You only have one copy or metadata, and it's corrupted.
>
> It may be possible to repair, but it's definitely not reliable and I
> won't recommend to do it.
>
> All you can do is try to salvage the data, by mounting with
> "rescue=all,ro" which should give you some chance to read out some
> data.
Oh this is very useful, thanks. I tried btrfs-rescue as a separate
command and only could reach a handful files. Using it as a mount
option does give me a more complete-looking directory tree. As
expected, a few files have errors reading them, but most of them do
open fine.
> > 2. Does it make sense to drop down the filesystem to read-only when
> > the
> > underlying drive starts exhibiting errors?
>
> For your case, it makes no difference.
Oh sure. This isn't a question to fix anything for me now. This is
just a way of throwing out a suggestion for a future feature - whether
something like that makes sense.
> Your metadata is only SINGLE, and that's your choice, so there is no
> repair anyway.
>
> Furthermore even with extra mirrors (e.g. DUP or RAID1), btrfs will
> only
> write the correct data/metadata into the bad one, thus it should not
> make things worse unless your hardware is totally screwed up.
Yea, that's understandable, of course.
Thanks a lot for the mount option hint, it has already helped me poke
around the file system.
Amit
next prev parent reply other threads:[~2026-04-02 18:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 15:58 Fixing a corrupted file system Amit Shah
2026-04-01 21:21 ` Qu Wenruo
2026-04-02 18:18 ` Amit Shah [this message]
2026-04-02 18:32 ` remi
2026-04-02 18:52 ` Amit Shah
2026-04-02 19:07 ` Forza
2026-04-24 8:23 ` Ulli Horlacher
2026-04-24 12:49 ` Roman Mamedov
2026-04-24 18:10 ` How to corrupt a btrfs fs [was Re: Fixing a corrupted file system] Nicholas D Steeves
2026-04-24 18:16 ` Roman Mamedov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cc26312ada6ced3283bf36d249487ff7604604f9.camel@infradead.org \
--to=amit@infradead.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox