From: Qu Wenruo <wqu@suse.com>
To: Amit Shah <amit@infradead.org>, linux-btrfs@vger.kernel.org
Subject: Re: Fixing a corrupted file system
Date: Thu, 2 Apr 2026 07:51:51 +1030 [thread overview]
Message-ID: <fc202c52-cb3e-40b2-a80a-6ffda886f76b@suse.com> (raw)
In-Reply-To: <8c8e2466574b29ba1da29c325a108824c8373a85.camel@infradead.org>
在 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.
So you only have one chance and lost that chance.
>
> # mount /dev/mapper/luks-ad4cc8e3-17c1-41f8-8d9d-bb831bfcef23
> /mnt/msatassd/
> mount: /mnt/msatassd: can't read superblock on /dev/mapper/luks-
> ad4cc8e3-17c1-41f8-8d9d-bb831bfcef23.
> dmesg(1) may have more information after failed mount system
> call.
>
> # dmesg|tail
> [960464.502742] BTRFS: device label msatafs devid 1 transid 772442
> /dev/mapper/luks-ad4cc8e3-17c1-41f8-8d9d-bb831bfcef23 scanned by mount
> (10021)
> [960464.516714] BTRFS info (device dm-0): first mount of filesystem
> 28fa4955-eadf-4f12-a34d-fb7405bbd0a5
> [960464.526014] BTRFS info (device dm-0): using crc32c (crc32c-generic)
> checksum algorithm
> [960464.534065] BTRFS info (device dm-0): disk space caching is enabled
> [960464.559255] BTRFS info (device dm-0): bdev /dev/mapper/luks-
> ad4cc8e3-17c1-41f8-8d9d-bb831bfcef23 errs: wr 0, rd 0, flush 0, corrupt
> 100, gen 0
> [960464.607016] BTRFS error (device dm-0): bad tree block start, mirror
> 1 want 1116258304 have 5031253079992706228
> [960464.617170] BTRFS error (device dm-0): failed to read block groups:
> -5
> [960464.626009] BTRFS error (device dm-0): open_ctree failed: -5
>
>
> (I also have the raw file that I can loop-mount instead of using this
> other drive, but for this experiment, working on the drive is simpler
> to iterate.)
>
> So questions:
>
> 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.
>
> 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.
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.
Thanks,
Qu
>
> Thanks,
> Amit
>
next prev parent reply other threads:[~2026-04-01 21:21 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 [this message]
2026-04-02 18:18 ` Amit Shah
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=fc202c52-cb3e-40b2-a80a-6ffda886f76b@suse.com \
--to=wqu@suse.com \
--cc=amit@infradead.org \
--cc=linux-btrfs@vger.kernel.org \
/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