Cannot delete corrupted folder with `sudo rm -rf`

Hello Everyone!
I have a redundant node_modules folder in one of my coding projects which I would like to remove. However there are several folders inside the main node_modules folder which cannot be deleted due to an Input/Output error

$ ls -A
ls: cannot access 'build': Input/output error
build/
$ sudo rm -rf build/
rm: cannot remove 'build/': Input/output error

running btrfs scrub couldn’t resolve this issue:

$ sudo btrfs scrub status .
Scrub started:    Sun Oct  8 12:43:08 2023
Status:           finished
Duration:         0:03:42
Total to scrub:   200.61GiB
Rate:             925.32MiB/s
Error summary:    read=128 verify=48 csum=8
  Corrected:      127
  Uncorrectable:  57
  Unverified:     0

here’s the output of dmesg

[ 2407.781669] BTRFS info (device nvme0n1p6): scrub: started on devid 1
[ 2411.344875] nvme0n1: I/O Cmd(0x2) @ LBA 498589696, 1024 blocks, I/O Error (sct 0x2 / sc 0x81) MORE DNR 
[ 2411.344881] critical target error, dev nvme0n1, sector 498589696 op 0x0:(READ) flags 0x0 phys_seg 97 prio class 3
[ 2411.344884] BTRFS error (device nvme0n1p6): bdev /dev/nvme0n1p6 errs: wr 0, rd 37, flush 0, corrupt 0, gen 0
[ 2411.344887] BTRFS error (device nvme0n1p6): bdev /dev/nvme0n1p6 errs: wr 0, rd 38, flush 0, corrupt 0, gen 0
[ 2411.344888] BTRFS error (device nvme0n1p6): bdev /dev/nvme0n1p6 errs: wr 0, rd 39, flush 0, corrupt 0, gen 0
[ 2411.344890] BTRFS error (device nvme0n1p6): bdev /dev/nvme0n1p6 errs: wr 0, rd 40, flush 0, corrupt 0, gen 0
[ 2411.344891] BTRFS error (device nvme0n1p6): bdev /dev/nvme0n1p6 errs: wr 0, rd 41, flush 0, corrupt 0, gen 0
[ 2411.344893] BTRFS error (device nvme0n1p6): bdev /dev/nvme0n1p6 errs: wr 0, rd 42, flush 0, corrupt 0, gen 0
[ 2411.344894] BTRFS error (device nvme0n1p6): bdev /dev/nvme0n1p6 errs: wr 0, rd 43, flush 0, corrupt 0, gen 0
[ 2411.344895] BTRFS error (device nvme0n1p6): bdev /dev/nvme0n1p6 errs: wr 0, rd 44, flush 0, corrupt 0, gen 0
[ 2411.356487] BTRFS error (device nvme0n1p6): fixed up error at logical 1464926208 on dev /dev/nvme0n1p6 physical 2547056640
[ 2411.356490] BTRFS error (device nvme0n1p6): fixed up error at logical 1464926208 on dev /dev/nvme0n1p6 physical 2547056640
[ 2411.356491] BTRFS error (device nvme0n1p6): fixed up error at logical 1464926208 on dev /dev/nvme0n1p6 physical 2547056640
[ 2411.356492] BTRFS error (device nvme0n1p6): fixed up error at logical 1464926208 on dev /dev/nvme0n1p6 physical 2547056640
[ 2411.356493] BTRFS error (device nvme0n1p6): fixed up error at logical 1464926208 on dev /dev/nvme0n1p6 physical 2547056640
[ 2411.356493] BTRFS error (device nvme0n1p6): fixed up error at logical 1464926208 on dev /dev/nvme0n1p6 physical 2547056640
[ 2411.356494] BTRFS error (device nvme0n1p6): fixed up error at logical 1464926208 on dev /dev/nvme0n1p6 physical 2547056640
[ 2411.356495] BTRFS error (device nvme0n1p6): fixed up error at logical 1464926208 on dev /dev/nvme0n1p6 physical 2547056640
[ 2411.356495] BTRFS error (device nvme0n1p6): fixed up error at logical 1464926208 on dev /dev/nvme0n1p6 physical 2547056640
[ 2411.356496] BTRFS error (device nvme0n1p6): fixed up error at logical 1464926208 on dev /dev/nvme0n1p6 physical 2547056640
[ 2411.417927] nvme0n1: I/O Cmd(0x2) @ LBA 498590704, 8 blocks, I/O Error (sct 0x2 / sc 0x81) MORE DNR 
[ 2411.417933] critical target error, dev nvme0n1, sector 498590704 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
[ 2411.417936] BTRFS error (device nvme0n1p6): bdev /dev/nvme0n1p6 errs: wr 0, rd 45, flush 0, corrupt 0, gen 0
[ 2411.418817] BTRFS error (device nvme0n1p6): unable to fixup (regular) error at logical 1465319424 on dev /dev/nvme0n1p6 physical 2547449856
[ 2411.418876] BTRFS warning (device nvme0n1p6): i/o error at logical 1465319424 on dev /dev/nvme0n1p6, physical 2547449856, root 257, inode 25480395, offset 643072, length 4096, links 1 (path: censored/.config/BraveSoftware/Brave-Browser/Default/Extension Scripts/000016.log)
[ 2577.349713] BTRFS warning (device nvme0n1p6): tree block 295040483328 mirror 1 has bad csum, has 0xc4ab588a want 0x43acdeae
[ 2577.349717] BTRFS warning (device nvme0n1p6): tree block 295040516096 mirror 1 has bad csum, has 0xa116c1c5 want 0x17604b4e
[ 2577.349734] BTRFS warning (device nvme0n1p6): tree block 295040532480 mirror 1 has bad csum, has 0xac6c7f15 want 0x7aa75578
[ 2577.349738] BTRFS warning (device nvme0n1p6): tree block 295040548864 mirror 1 has bad csum, has 0x6bd0d228 want 0x8f3b287a
[ 2577.349739] BTRFS warning (device nvme0n1p6): tree block 295040565248 mirror 1 has bad bytenr, has 0 want 295040565248
[ 2577.349738] BTRFS warning (device nvme0n1p6): tree block 295040663552 mirror 1 has bad csum, has 0xd67ab187 want 0xacfe36b1
[ 2577.349761] BTRFS warning (device nvme0n1p6): tree block 295040696320 mirror 1 has bad csum, has 0xf50ab9ef want 0x9bb62ee9
[ 2577.350929] BTRFS warning (device nvme0n1p6): tree block 295040483328 mirror 1 has bad csum, has 0xc4ab588a want 0x43acdeae
[ 2577.350986] BTRFS warning (device nvme0n1p6): tree block 295040663552 mirror 1 has bad csum, has 0xd67ab187 want 0xacfe36b1
[ 2577.350999] BTRFS warning (device nvme0n1p6): tree block 295040696320 mirror 1 has bad csum, has 0xf50ab9ef want 0x9bb62ee9
[ 2577.351062] BTRFS warning (device nvme0n1p6): tree block 295040516096 mirror 1 has bad csum, has 0xa116c1c5 want 0x17604b4e
[ 2577.351068] BTRFS warning (device nvme0n1p6): tree block 295040565248 mirror 1 has bad bytenr, has 0 want 295040565248
[ 2577.358630] BTRFS error (device nvme0n1p6): unable to fixup (regular) error at logical 295040450560 on dev /dev/nvme0n1p6 physical 203780784128
[ 2577.358639] BTRFS error (device nvme0n1p6): unable to fixup (regular) error at logical 295040450560 on dev /dev/nvme0n1p6 physical 203780784128
[ 2577.358640] BTRFS error (device nvme0n1p6): unable to fixup (regular) error at logical 295040450560 on dev /dev/nvme0n1p6 physical 203780784128
[ 2577.358642] BTRFS error (device nvme0n1p6): unable to fixup (regular) error at logical 295040450560 on dev /dev/nvme0n1p6 physical 203780784128
[ 2577.359338] BTRFS warning (device nvme0n1p6): tree block 295040565248 mirror 1 has bad bytenr, has 0 want 295040565248
[ 2577.359597] BTRFS error (device nvme0n1p6): unable to fixup (regular) error at logical 295040647168 on dev /dev/nvme0n1p6 physical 203780980736
[ 2577.359601] BTRFS error (device nvme0n1p6): unable to fixup (regular) error at logical 295040647168 on dev /dev/nvme0n1p6 physical 203780980736
[ 2577.359603] BTRFS error (device nvme0n1p6): unable to fixup (regular) error at logical 295040647168 on dev /dev/nvme0n1p6 physical 203780980736
[ 2577.359604] BTRFS error (device nvme0n1p6): unable to fixup (regular) error at logical 295040647168 on dev /dev/nvme0n1p6 physical 203780980736
[ 2577.359606] BTRFS error (device nvme0n1p6): unable to fixup (regular) error at logical 295040647168 on dev /dev/nvme0n1p6 physical 203780980736
[ 2577.359607] BTRFS error (device nvme0n1p6): unable to fixup (regular) error at logical 295040647168 on dev /dev/nvme0n1p6 physical 203780980736
[ 2577.360971] BTRFS warning (device nvme0n1p6): tree block 295040565248 mirror 1 has bad bytenr, has 0 want 295040565248
[ 2577.933994] BTRFS warning (device nvme0n1p6): tree block 295040565248 mirror 2 has bad bytenr, has 0 want 295040565248
[ 2577.941972] BTRFS warning (device nvme0n1p6): tree block 295040565248 mirror 2 has bad bytenr, has 0 want 295040565248
[ 2577.943580] BTRFS warning (device nvme0n1p6): tree block 295040565248 mirror 2 has bad bytenr, has 0 want 295040565248
[ 2577.945252] BTRFS warning (device nvme0n1p6): tree block 295040565248 mirror 2 has bad bytenr, has 0 want 295040565248
[ 2630.215341] BTRFS info (device nvme0n1p6): scrub: finished on devid 1 with status: 0

Is there any way I can delete the corrupted folders? thanks in advance.
Environment: Fedora 38 matecompiz spin.

This maybe a result of a hardware problem.

What is the output of smartctl -a /dev/nvme0 ?

Did you force a power off without a software shutdown?

Hello, here’s the log of the command you requested.

smartctl 7.4 2023-08-01 r5530 [x86_64-linux-6.5.5-200.fc38.x86_64] (local build)
Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Number:                       SAMSUNG MZVLQ512HBLU-00B00
Serial Number:                      S6F5NA0T234240
Firmware Version:                   FXM7201Q
PCI Vendor/Subsystem ID:            0x144d
IEEE OUI Identifier:                0x002538
Total NVM Capacity:                 512,110,190,592 [512 GB]
Unallocated NVM Capacity:           0
Controller ID:                      5
NVMe Version:                       1.4
Number of Namespaces:               1
Namespace 1 Size/Capacity:          512,110,190,592 [512 GB]
Namespace 1 Utilization:            402,985,058,304 [402 GB]
Namespace 1 Formatted LBA Size:     512
Namespace 1 IEEE EUI-64:            002538 d22103211e
Local Time is:                      Sun Oct  8 22:14:28 2023 +04
Firmware Updates (0x16):            3 Slots, no Reset required
Optional Admin Commands (0x0017):   Security Format Frmw_DL Self_Test
Optional NVM Commands (0x0057):     Comp Wr_Unc DS_Mngmt Sav/Sel_Feat Timestmp
Log Page Attributes (0x0f):         S/H_per_NS Cmd_Eff_Lg Ext_Get_Lg Telmtry_Lg
Maximum Data Transfer Size:         512 Pages
Warning  Comp. Temp. Threshold:     83 Celsius
Critical Comp. Temp. Threshold:     85 Celsius
Namespace 1 Features (0x10):        NP_Fields

Supported Power States
St Op     Max   Active     Idle   RL RT WL WT  Ent_Lat  Ex_Lat
 0 +     5.36W       -        -    0  0  0  0        0       0
 1 +     4.47W       -        -    1  1  1  1        0       0
 2 +     2.23W       -        -    2  2  2  2        0     500
 3 -   0.0500W       -        -    3  3  3  3      210    1200
 4 -   0.0050W       -        -    4  4  4  4     1000    9000

Supported LBA Sizes (NSID 0x1)
Id Fmt  Data  Metadt  Rel_Perf
 0 +     512       0         0

=== START OF SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

SMART/Health Information (NVMe Log 0x02)
Critical Warning:                   0x00
Temperature:                        40 Celsius
Available Spare:                    99%
Available Spare Threshold:          10%
Percentage Used:                    6%
Data Units Read:                    69,213,249 [35.4 TB]
Data Units Written:                 38,127,342 [19.5 TB]
Host Read Commands:                 895,170,313
Host Write Commands:                691,717,892
Controller Busy Time:               2,436
Power Cycles:                       1,120
Power On Hours:                     1,353
Unsafe Shutdowns:                   92
Media and Data Integrity Errors:    74
Error Information Log Entries:      74
Warning  Comp. Temperature Time:    0
Critical Comp. Temperature Time:    0
Temperature Sensor 1:               40 Celsius
Thermal Temp. 1 Transition Count:   3531
Thermal Temp. 2 Transition Count:   14
Thermal Temp. 1 Total Time:         3522
Thermal Temp. 2 Total Time:         3

Error Information (NVMe Log 0x01, 16 of 64 entries)
Num   ErrCount  SQId   CmdId  Status  PELoc          LBA  NSID    VS  Message
  0         74     4  0x70db  0xc502  0x000    498590704     1     -  Unrecovered Read Error
  1         73     9  0xd080  0xc502  0x000    498590704     1     -  Unrecovered Read Error

Self-test Log (NVMe Log 0x06)
Self-test status: No self-test in progress
No Self-tests Logged

Did you force a power off without a software shutdown?

I had to do manual shutdown several times after interacting with the node_modules folder (the folder I am trying to delete) because I got a filesystem is read only error and couldn’t shutdown my laptop normally. I do not get such errors when interacting with other files, only files in that specific folder.

I think tour ssd is failing.
I recommend you backup as much data from the ssd as you can and replace the drive.

These are not good.

I think this is saying that blocks of flush have failed and its useing up the spare blocks.

Other people may have more experience with interpreting the output.

1 Like