Btrfs has become read only

unresolved

I left my system running overnight and woke up to my Btrfs root filesystem being read only, any help would be much appreciated.

$ uname -a
Linux Slave 4.14.8-1-ARCH #1 SMP PREEMPT Wed Dec 20 21:27:44 UTC 2017 x86_64 GNU/Linux

$ btrfs --version
btrfs-progs v4.14

$ btrfs fi show
ERROR: cannot open /dev/sda2: Permission denied

$ btrfs fi df /
Data, single: total=314.01GiB, used=275.72GiB System, single: total=4.00MiB, used=64.00KiB Metadata, single: total=2.01GiB, used=783.03MiB GlobalReserve, single: total=353.81MiB, used=0.00B

$ dmesg | grep "error"
[ 105.088420] BTRFS: Transaction aborted (error -17) [ 105.088600] BTRFS: error (device sda2) in btrfs_run_delayed_refs:3089: errno=-17 Object already exists [ 105.122449] BTRFS error (device sda2): pending csums is 11726848

Edit: I got the dmesg output for when it happens

Posted Jan 3, 2018, 10:01 AM UTC · edited

84
[deleted]•

[deleted]

1
dedit8OP•

My fstab:

/etc/fstab: static file system information

<file system> <dir> <type> <options> <dump> <pass>

/dev/sda2

UUID=d479c627-1381-44dc-b7ed-26e4d60f099c / btrfs rw,relatime,ssd,space_cache,subvolid=5,subvol=/ 0 0

/dev/sda1

UUID=A3EA-234A /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 2

#/home #UUID=1d827674-ea5e-46f9-9f8c-a9a47fd7475a /home ext4 nodev,nosuid 0 2

1
dedit8OP•

Result of Btrfs check: https://imgur.com/0jVKWVc

1
[deleted]•

Likely you'used up all the space reserved to ordinary files (DATA) and what's left is the mostly unused Meta-data reserved space, you cannot access. Btrfs is a new generation File System and does not simply allocate FS space berween free and used, as opposite devides partition into subvolumes, and this can lead to the paradox where:

  • df -h shows a 100% full partition (try it)

  • btrfs fylesystem df / shows a full DATA subvolume (see Data, Single), and almost empty Metadata, DUP

Unlike other new Gen FSs, like ZFS, HAMMER and APFS, Btrfs is IMHO still somehow immature, and should not be used (despite all of its advantages that I agree with you, are really tempting!) unless you know what you're doing.

To understand your (probable) problem, please read Btrfs FAQs on: [Help! Btrfs claims I'm out of space, but it looks like I should have lots left!] (https://btrfs.wiki.kernel.org/index.php/FAQ#Help.21_Btrfs_claims_I.27m_out_of_space.2C_but_it_looks_like_I_should_have_lots_left.21)

Reading the whole FAQs and the wiki would be a good idea as well. I know, it's long, but it's really worthwhile and you'll learn about many more things your Btrfs partition can actually do.

For the time being, try running:

btrfs balance start -m /

Now, to clear free space cache, mount the Btrfs partition with:

-oclear_cache

Then, to rebuild the cache, mount the Btrfs partition with:

-ospace_cache

It will take some time

2
ndc33•

you should what distro your using. doing a btrfs scrub would also be useful.

1