BTRFS became read-only

Not sure if related, but today I had a weird KDE bug (monitors off on startup), so I rebooted into Windows to fix KDE by editing its config file. At first I tried WinBtrfs, it didn’t work, then I added the disk into VirtualBox as physical disk and mounted/fixed what I needed via EOS ISO.

After that everything was fine, but after several hours my system became read-only.

I rebooted and it seems to work so far.

There were these messages in journalctl after reboot

ноя 28 22:00:07 alex-eos kernel: BTRFS error (device nvme1n1p2): incorrect extent count for 895531089920; counted 18, expected 19
ноя 28 22:00:07 alex-eos kernel: BTRFS error (device nvme1n1p2): incorrect extent count for 682930208768; counted 140, expected 141
ноя 28 22:00:07 alex-eos kernel: BTRFS error (device nvme1n1p2): incorrect extent count for 705478787072; counted 275, expected 276
ноя 28 22:00:07 alex-eos kernel: BTRFS error (device nvme1n1p2): incorrect extent count for 688298917888; counted 121, expected 122
ноя 28 22:00:07 alex-eos kernel: BTRFS error (device nvme1n1p2): incorrect extent count for 655012921344; counted 132, expected 133
ноя 28 22:00:07 alex-eos kernel: BTRFS error (device nvme1n1p2): incorrect extent count for 718363688960; counted 19, expected 20
ноя 28 22:00:07 alex-eos kernel: BTRFS error (device nvme1n1p2): incorrect extent count for 670045306880; counted 73, expected 74
ноя 28 22:00:07 alex-eos kernel: BTRFS error (device nvme1n1p2): incorrect extent count for 694741368832; counted 23, expected 24

and about this before reboot (missing now).

... state EA: parent transid verify failed on logical ...

What should I do?

I have some Timeshift snapshots of the system volume (and normal backups of course).

It looks like your btrfs filesystem is corrupt.

Snapshots won’t help with this situation.

Take a look at this:
https://btrfs.readthedocs.io/en/latest/btrfs-check.html

It became read-only again when I launched an app reading/writing lots of caches.

ноя 29 07:12:50 alex-eos kernel: BTRFS: error (device nvme1n1p2: state EA) in btrfs_run_delayed_refs:2141: errno=-5 IO failure
ноя 29 07:12:50 alex-eos kernel: BTRFS: error (device nvme1n1p2: state EA) in do_free_extent_accounting:2843: errno=-5 IO failure
ноя 29 07:12:50 alex-eos kernel: BTRFS: error (device nvme1n1p2: state EA) in add_to_free_space_tree:1051: errno=-5 IO failure
ноя 29 07:12:50 alex-eos kernel: BTRFS info (device nvme1n1p2: state EA): forced readonly
ноя 29 07:12:50 alex-eos kernel: BTRFS: error (device nvme1n1p2: state A) in convert_free_space_to_bitmaps:333: errno=-5 IO failure
ноя 29 07:12:50 alex-eos kernel: BTRFS error (device nvme1n1p2): incorrect extent count for 259875930112; counted 1438, expected 1439

btrfs-check output:

btrfs check --force /dev/nvme1n1p2
Opening filesystem to check...
WARNING: filesystem mounted, continuing because of --force
Checking filesystem on /dev/nvme1n1p2
UUID: 2ed879cf-e973-477c-8253-2a244e3e6537
[1/7] checking root items
[2/7] checking extents
[3/7] checking free space tree
free space info recorded 138 extents, counted 137
there is no free space entry for 125545517056-125545521152
cache appears valid but isn't 124584460288
free space info recorded 199 extents, counted 198
there is no free space entry for 129913212928-129913221120
cache appears valid but isn't 128879427584
free space info recorded 56 extents, counted 55
wanted bytes 20480, found 16384 for off 133153652736
cache appears valid but isn't 132100653056
free space info recorded 817 extents, counted 816
wanted bytes 20480, found 16384 for off 260918263808
cache appears valid but isn't 259875930112
free space info recorded 2718 extents, counted 2692
there is no free space entry for 409117659136-409117671424
cache appears valid but isn't 408052301824
free space info recorded 501 extents, counted 500
there is no free space entry for 418787696640-418787700736
cache appears valid but isn't 417715978240
free space info recorded 221 extents, counted 220
there is no free space entry for 426302242816-426302246912
cache appears valid but isn't 425232171008
free space info recorded 61 extents, counted 60
there is no free space entry for 430545145856-430545149952
cache appears valid but isn't 429527138304
free space info recorded 403 extents, counted 402
there is no free space entry for 443483992064-443483996160
cache appears valid but isn't 442412040192
free space info recorded 601 extents, counted 600
there is no free space entry for 446684819456-446684823552
cache appears valid but isn't 445633265664
free space info recorded 137 extents, counted 136
there is no free space entry for 452073574400-452073578496
cache appears valid but isn't 451001974784
free space info recorded 171 extents, counted 170
there is no free space entry for 456317480960-456317489152
cache appears valid but isn't 455296942080
free space info recorded 76 extents, counted 75
there is no free space entry for 488502149120-488502157312
cache appears valid but isn't 487509196800
free space info recorded 461 extents, counted 460
there is no free space entry for 512181936128-512181940224
cache appears valid but isn't 511131516928
free space info recorded 1149 extents, counted 1148
there is no free space entry for 516498714624-516498722816
cache appears valid but isn't 515426484224
free space info recorded 430 extents, counted 429
wanted bytes 24576, found 20480 for off 518629404672
cache appears valid but isn't 517573967872
free space info recorded 762 extents, counted 761
there is no free space entry for 521739239424-521739247616
cache appears valid but isn't 520795193344
free space info recorded 156 extents, counted 155
there is no free space entry for 544365944832-544365953024
cache appears valid but isn't 543343771648
free space info recorded 697 extents, counted 696
there is no free space entry for 550801694720-550801707008
cache appears valid but isn't 549786222592
free space info recorded 115 extents, counted 114
there is no free space entry for 638905716736-638905745408
cache appears valid but isn't 637833052160
free space info recorded 133 extents, counted 132
there is no free space entry for 656078348288-656078368768
cache appears valid but isn't 655012921344
free space info recorded 255 extents, counted 254
there is no free space entry for 662529089536-662529105920
cache appears valid but isn't 661455372288
free space info recorded 74 extents, counted 73
there is no free space entry for 671118757888-671118766080
cache appears valid but isn't 670045306880
free space info recorded 141 extents, counted 140
there is no free space entry for 684003917824-684003930112
cache appears valid but isn't 682930208768
free space info recorded 120 extents, counted 119
there is no free space entry for 689267122176-689267138560
cache appears valid but isn't 688298917888
free space info recorded 24 extents, counted 23
there is no free space entry for 695815090176-695815098368
cache appears valid but isn't 694741368832
free space info recorded 278 extents, counted 277
there is no free space entry for 706552512512-706552528896
cache appears valid but isn't 705478787072
free space info recorded 20 extents, counted 19
there is no free space entry for 719437185024-719437205504
cache appears valid but isn't 718363688960
free space info recorded 334 extents, counted 333
there is no free space entry for 766559322112-766559330304
cache appears valid but isn't 765608329216
free space info recorded 19 extents, counted 18
there is no free space entry for 896587808768-896587821056
cache appears valid but isn't 895531089920
[4/7] checking fs roots
[5/7] checking only csums items (without verifying data)
[6/7] checking root refs
[7/7] checking quota groups skipped (not enabled on this FS)
found 1612618100819 bytes used, error(s) found
total csum bytes: 1181777548
total tree bytes: 9816588288
total fs tree bytes: 7860289536
total extent tree bytes: 511672320
btree space waste bytes: 1531983193
file data blocks allocated: 1693176115200
 referenced 1804296577024

I never thought Virtualbox runs on Windows to access Linux on the physical disk.

Oracle VirtualBox document:

Warning
Raw hard disk access is for expert users only. Incorrect use or use of an outdated configuration can lead to total loss of data on the physical disk. Most importantly, do not attempt to boot the partition with the currently running host operating system in a guest. This will lead to severe data corruption.

Don’t use VM to access the physical disk. Just use TTY or Live USB to chroot your system.

1 Like

Well, I think I did it correctly :slight_smile: Not booting of course, just booting the EOS ISO and mounting it.

SeverWatch document:

Warning: Do not attempt to mount or boot the partition that runs the host OS with a VM, as that can lead to severe data corruption. And no matter which drive or partition you want to mount, it’s always a good idea to back up any existing data on it before continuing.

I think they mean mounting the disk currently running the host OS.

I guess the corruption by WinBtrfs is more likely, if it tried to do something weird. No idea if it actually did something or did not start at all, I only installed it, did not see any volumes show up, and uninstalled it (after enabling options about automount and something related to the driver signing, which did not change anything).

Yes, probably.

Just think, better not use VM and WinBtrfs on Windows to fix your serious system on the Linux partition.

Just use TTY to fix some configuration when SDDM login or KDE crashes.
When kernel or GRUB or filesystem fails, then chroot to your system via Live USB.

Copy files to external drive, reformat BTRFS, run r/w disk checks just to be sure and copy data back.