There are 2 different problems here, and each has different mechanics and different fixes.

#1. when the volume is actually full and reports 100% usage (in df) – error message below in red

#2. when the volume is not full, but says its out of space – error message below in red

Note if the console/terminal doesnt show the error. dmesg output will show it

#1. When the volume is actually full and reports 100% usage (in df)

BTRFS doesnt allow to mount Read/Write if its 100% full. But you can mount it as read only, to find which files are filling it up. Well whats the use if you cant get rid of them (deleting is still writing)?

dmesg will say things like this

BTRFS error (device md0) in __btrfs_free_extent:5561: errno=-28 No space left. btrfs is forced readonly.

Well actually there is a way to mount as read/write, 2 ways (and 1 way which is kind of a hassle). 1 common way and 1 mysterious way that I found.

FIX1 – Common way:

mount /dev/md0 /mnt-t btrfs '-onospace_cache,clear_cache,enospc_debug,nodatacow'

UPDATE 2015-12-03: Read up about running the above command differently now http://www.infotinks.com/btrfs-recovery-mount-ultimate-mount-command/

 FIX2 – My mysterious way:

# First mount as readonly
mount -o ro /dev/md0 /mnt
# Then remount as read write
mount -o remount,rw /dev/md0 /mnt
# ah but it fails, right... it wouldnt be that easy...
# repeat the command (with up arrow & enter)
mount -o remount,rw /dev/md0 /mnt
# VOILA, if that doesn't work repeat a couple more times (always works for me after 1 or 2 repeats)

NOTE: if anyone can explain why FIX2 works then your here by declared smart and awesome

After mounting read write: Delete your big files, And do a balance (with a small dusage value that you increment, doing it with increments allows for more thourough and faster completion time)

# After mounting as read write and deleting big files, run a sync to be on safe side:
sync
# time to balance
# balance time (it will only balance chunks that have i% of data)
# this is useful for single device btrfs vols as well
for i in 0 1 2 3 4 5 10 15 20; do echo "===balancing with dusage $i==="; btrfs balance start -dusage=$i /mnt; done;
# sync again, unmount and remount to make sure works
sync
umount /mnt
mount /dev/md0 /mnt

#2. When metadata full but data not full

Here the problem is the volume mounts as read write (so normal mount works), however any writes or changes bring up the error in red below.

BTRFS writes data into chunks of 3 categories (data, metadata and system), it therefor has the con of having to do allocation. The allocation algorithm might be off and not give enough space for data, and favor more metadata. This error could arise: In reality there will be space left but the device will report no space left (this is unlike the above problem #1 where in #1 there was actually no space left).

NOTE: This article of mine explains allocation (and this problem more in detail towards the bottom of the article): http://www.infotinks.com/btrfs-fi-df-balance-btrfs-df/

NOTE: Below article covers this problem as well: http://marc.merlins.org/perso/btrfs/post_2014-05-04_Fixing-Btrfs-Filesystem-Full-Problems.html

To fix this problem you just need to do a balance.

# simple way
btrfs balance start -v -dusage=0 /data

# or to be more fancy and percise:
for i in 0 1 2 3 4 5 10 15 20; do echo "===balancing with dusage $i==="; btrfs balance start -dusage=$i /mnt; done;

Now if you get the error:

ERROR: error during balancing ‘/data/’ – No space left on device

Then you will need to clear up space (maybe using the above method), or what if you dont want to clear up space (Because after all you should have that free space allocated for use), then you can use the following trick.

Add a device to the btrfs volume. Then Balance it. Then remove the device.

# add the device /dev/sdf (which can be something as simple as 4gig USB)
btrfs device add /dev/sdf /mnt

# now delete any snapshots or files

# remove the USB
btrfs device delete /dev/sdf /mnt

# now run the balance
btrfs balance start -v -dusage=0 /mnt

# or run the for loop balance from above
for i in 0 1 2 3 4 5 10 15 20; do echo "===balancing with dusage $i==="; btrfs balance start -dusage=$i /mnt; done;

One thought on “BTRFS cant mount Read/Write because Full or Out of Space issues – 2 problems

  1. I tried for the same issue on root:

    snapper list
    snapper remove xx-xx (where xx is a number of snapshot)

    mount -o remount,rw /
    btrfs balance start /

    all these commands didn’t work because BTRFS is in forced read-only mode, and acts like it’s full (no space left)

    is there a way to make it rw besides this

Leave a Reply

Your email address will not be published. Required fields are marked *