[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Fixing errors on a BTRFS partition?



On Thu, Jan 12, 2023 at 14:10:22 +0000, piorunz wrote:
> To satiate your curiosity, you can find out what files are corrupted, some
> of the errors are giving filenames. If not, this is my saved command to
> obtain filename from inode numbers:
> sudo btrfs inspect-internal inode-resolve 50845 /
> 
> And obtain filename from logical error:
> sudo btrfs inspect-internal logical-resolve -v 540115857408 /
> 
> As far as I know, Btrfs may refuse to read file with wrong checksum, there
> may be another command to do that.

I believe mounting with -o rescue=all will allow to read corrupted files,
so the remaining parts of non-replaceable files can be salvaged; though I
fortunately never had to put this to test myself. Specifically the
ignoredatacsums setting, see
  https://btrfs.readthedocs.io/en/stable/Administration.html#mount-options

Note that this requires a sufficiently new kernel.


On Thu, Jan 12, 2023 at 08:58:52 -0500, Dan Ritter wrote:
> For the future: don't let things go this long. I know it's
> tempting to say "maybe it won't happen again", but the second
> time should be the last time before you take action.

To add to this: usually it is recommended to regularly run `btrfs scrub`
to detect (and in case of redunancy repair) data degradation. Running also
`btrfs check` regularly to verify the fs structure also isn't a bad idea.
This makes it more likely you'll notice a failing device before it gets
as bad as it is now.

> 2: Reinstall Debian on the new disk. Don't use btrfs on a
> single-drive system; only use btrfs on a mirrored system. In most cases,
> use ext4.

For the record, I don't agree with BTRFS only being useful with RAID.
BTRFS’ scrub and check can detect corruption early, rather then bitrot
silently continuing until it starts crashing and there might be other
features like e.g. transparent compression which might make it worthwhile
for one’s single-device usecases.
(In theory redunancy can also be used with a single device by creating the
FS with the "dup" data profile, but this of course offers les protection
than separate devices.)


Reply to: