From: "Henri Hyyryläinen" <henri.hyyrylainen@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: How to remove an unremovable file and directory?
Date: Mon, 29 Sep 2025 20:11:40 +0300 [thread overview]
Message-ID: <33570321-604e-4830-843a-4ed839dfbe83@gmail.com> (raw)
Hello,
I hope this is the right place to ask about a filesystem problem. Really
shortly put, I have a file that both exists and doesn't and prevents the
containing directory from being deleted. No matter what variant of rm
and inode based deletion I try I get an error about the file not
existing, and I also cannot try to read the file, but if I try to delete
the directory I get an error that it is not empty (so the file kind of
exists). Trying to ls the directory also gives a file doesn't exist error.
Here's what btrfs check found, which I hope does better in illustrating
the problem:
> root 5 inode 25953213 errors 200, dir isize wrong
> root 5 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
I've tried everything I've found suggested including a full scrub,
balance with -dusage=75 -musage=75, resetting file attributes, deleting
through the find command, and even some repair mount flags that don't
seem to exist for btrfs. What I haven't tried is a full rebalance with
no filters, but I did not try that yet as it would take quite a long
time and if it only moves data blocks around without recomputing
directory items, it doesn't seem like the right tool to fix my problem.
So I'm pretty much stuck and to me it seems like my only option is to
run btrfs check with the repair flag, but as that has big warnings on it
I thought I would try asking here first (sorry if this is not the right
experts group to ask). So is there still something I can try or am I
finally "allowed" to use the repair command? Here's the full output I
got from btrfs check:
> Opening filesystem to check...
> Checking filesystem on /dev/sdc
> UUID: 2b4ad16d-e456-4adf-960b-dca43560b98b
> [1/8] checking log skipped (none written)
> [2/8] checking root items
> [3/8] checking extents
> [4/8] checking free space tree
> We have a space info key for a block group that doesn't exist
> [5/8] checking fs roots
> root 5 inode 25953213 errors 200, dir isize wrong
> root 5 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
> root 14428 inode 25953213 errors 200, dir isize wrong
> root 14428 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
> root 14451 inode 25953213 errors 200, dir isize wrong
> root 14451 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
> root 14475 inode 25953213 errors 200, dir isize wrong
> root 14475 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
> root 14499 inode 25953213 errors 200, dir isize wrong
> root 14499 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
> root 14523 inode 25953213 errors 200, dir isize wrong
> root 14523 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
> root 14544 inode 25953213 errors 200, dir isize wrong
> root 14544 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
> root 14545 inode 25953213 errors 200, dir isize wrong
> root 14545 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
> root 14546 inode 25953213 errors 200, dir isize wrong
> root 14546 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
> root 14547 inode 25953213 errors 200, dir isize wrong
> root 14547 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
> root 14548 inode 25953213 errors 200, dir isize wrong
> root 14548 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
> root 14549 inode 25953213 errors 200, dir isize wrong
> root 14549 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
> root 14550 inode 25953213 errors 200, dir isize wrong
> root 14550 inode 27166085 errors 2000, link count wrong
> unresolved ref dir 25953213 index 7 namelen 33 name
> Microsoft.AspNetCore.Metadata.dll filetype 1 errors 1, no dir item
> ERROR: errors found in fs roots
> found 49400296812544 bytes used, error(s) found
> total csum bytes: 48179330432
> total tree bytes: 65067483136
> total fs tree bytes: 12107431936
> total extent tree bytes: 3194437632
> btree space waste bytes: 4558984171
> file data blocks allocated: 76487982252032
> referenced 60030799097856
So hopefully if I'm reading things right, running a repair would delete
just that one file and directory (which itself is a backup so I will not
miss that file at all)?
I do not have enough disk space to copy off the entire filesystem and
rebuild from scratch, without doing something like rebalancing all data
from raid10 to single and then removing half the disks, but I assume
that would take at least 4 weeks to process (as I just replaced a disk
which took like a week).
As to what originally caused the corruption, I think it was probably
faulty RAM, because up to to like 3 weeks ago I had one really bad RAM
stick in my computer where a certain memory region always had
incorrectly reading bytes. I had seen intermittent quite high csum
errors in monthly scrubs pretty randomly, which thankfully could almost
always be corrected so I didn't have any major problems even though I
had like totally broken RAM in my computer for who knows how long. So
btrfs was able to protect my data quite impressively from bad RAM.
Sorry for getting a bit sidetracked there, but what should I do in this
situation?
- Henri Hyyryläinen
next reply other threads:[~2025-09-29 17:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 17:11 Henri Hyyryläinen [this message]
2025-09-29 21:52 ` How to remove an unremovable file and directory? Qu Wenruo
2025-09-30 8:13 ` Henri Hyyryläinen
2025-10-04 17:43 ` Henri Hyyryläinen
2025-10-04 20:44 ` Qu Wenruo
2025-10-04 20:55 ` Qu Wenruo
2025-10-04 21:53 ` Henri Hyyryläinen
2025-10-04 22:07 ` Qu Wenruo
2025-10-04 22:36 ` Henri Hyyryläinen
2025-10-04 22:41 ` Qu Wenruo
2025-10-05 8:20 ` Henri Hyyryläinen
2025-10-05 8:37 ` Qu Wenruo
2025-10-05 10:44 ` Henri Hyyryläinen
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=33570321-604e-4830-843a-4ed839dfbe83@gmail.com \
--to=henri.hyyrylainen@gmail.com \
--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