Skip to content

Instantly share code, notes, and snippets.

@jumski
Last active June 11, 2025 15:18
Show Gist options
  • Save jumski/6446a157979768f1f9020d5c59061638 to your computer and use it in GitHub Desktop.
Save jumski/6446a157979768f1f9020d5c59061638 to your computer and use it in GitHub Desktop.
readonly fs bug

❯ sudo journalctl -xb | tail -1000 | ai are there any issues that would explain why i get the 'read only filesystem' everythere now Error: error returned from database: (code: 8) attempt to write a readonly database

Caused by: (code: 8) attempt to write a readonly database

Location: crates/atuin/src/command/client/history.rs:321:9

tl;dr: Your root filesystem has been remounted read-only due to a disk (BTRFS) error.


Let's break down your logs and why everything is read-only:

1. Symptoms

  • You have dozens of errors like EROFS: read-only file system, open '/home/jumski/.config/discord/logs/renderer_js.log'
  • Every desktop app (Firefox, Slack, Discord, Wireplumber, Klipper and more) is unable to write their normal files in your home directory.
  • You tried sudo mount -o remount,rw / and it made no difference.
  • The first mention of real trouble is around:
    cze 11 16:43:03 pc kernel: page: refcount:4 mapcount:0 mapping:000000001216a813 ...
    ...
    cze 11 16:43:06 pc discord[7883]: ... EROFS: read-only file system ...
    
  • Everything goes read-only after that.

2. The Root Cause: Filesystem/Hardware Error

When Linux (actually, the kernel) detects a serious disk or filesystem error, especially on btrfs, ext4, or similar filesystems, it will remount the affected partition as read-only to protect data/stop further corruption.

The tell-tale clues

  • The log line at 16:43:03 is from the kernel and is not a user application. (The kernel itself is reporting a bad memory/disk page.)
  • All write failures start right after this event.
  • EROFS ("Error Read-Only File System") is being returned by your kernel to all applications trying to write.
  • Attempts to remount as rw without fixing the underlying problem won't work (mount -o remount,rw / after kernel error does nothing until reboot + fsck).

Filesystem in your case

  • The log snippet shows aops:btree_aops [btrfs] ino:1 -- so your root is running on BTRFS.
  • Btrfs is more likely to remount root as read-only on corruption than, say, ext4.

3. How this happens

  • Bad sectors, power loss, dying SSD/HDD, or BTRFS bugs can cause this.
  • When the kernel can't successfully write/read parts of its filesystems, or encounters a critical error, it protects itself by remounting all or part of the FS as ro.
  • Especially common with BTRFS on older kernels or on physically failing disks.

4. What should you do?

a) Check Disk Health

First, check if your disk is failing!

For SSD/HDD (substitute sda for your actual disk):

sudo smartctl -a /dev/sda

Look for Reallocated_Sector_Ct, Current_Pending_Sector, Uncorrectable_Error_Cnt, etc.

b) Look for more kernel errors

Check for further BTRFS or I/O (Input/Output) errors:

sudo dmesg | egrep -i 'error|fail|btrfs|io'

c) Reboot and Run Filesystem Check

For BTRFS, you need to check the filesystem from a rescue system, or at least a root shell after reboot.

VERY IMPORTANT: Do NOT run btrfs check --repair on a mounted read-write (or even read-only) root. Best is to boot from a live USB system, then:

sudo btrfs check /dev/sdaX
# If it returns errors, then only if you understand the risks:
# sudo btrfs check --repair /dev/sdaX

Be sure /dev/sdaX is the partition your root BTRFS is on.

d) Backup anything important, immediately!

If the disk is failing, copying files (even in read-only mode!) is your best chance at saving irreplaceable data.


5. Summary / Why This Happens

  • You encountered a disk or filesystem error.
  • The kernel, to prevent data loss or further damage, remounted your root (btrfs) filesystem as read-only.
  • This instantly breaks anything that needs to write to disk, including application logs, browser caches, settings, etc.
  • Situation will only fix after you (1) fix the underlying issue (disk/FS) and (2) reboot the system.

What next? (step-by-step)

  1. Immediately back up anything valuable while you still can!
  2. Check your disk health (smartctl etc.)
  3. Review dmesg/journalctl for hardware/BTRFS errors.
  4. Reboot into a recovery/live USB (if needed) and run btrfs check.
  5. Replace the disk if hardware is failing. (Often the root cause.)
  6. Restore from backups if necessary.
  7. Update your kernel/BTRFS tools. Some BTRFS issues are fixed in recent updates.

References


If you want specific help:

Run:

sudo smartctl -a /dev/sda
sudo dmesg | tail -100 | egrep -i 'btrfs|error|fail'
sudo btrfs check /dev/sdaX

And paste the relevant output (replace device names with your actual disk/partition).


In summary: Your root filesystem (BTRFS on Manjaro) encountered a serious error/hardware failure and was automatically remounted read-only for your safety. Investigate and fix the hardware/filesystem; only then will normal operations resume. Back up your stuff right now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment