Skip to contentSkip to conversation

Change BTRFS filesystem back to R/W from R/O

DISCUSSION Forza 1 participant 1 message Nov 16, 2022 Btrfs file system

lore
Share & tools
lore

Forza

author
#0 lore raw

---- From: Spencer Collyer <[email protected]> -- Sent: 2022-11-15 - 15:08 ----

Quoted 12 lines

(Resending to the list as I accidentally sent it just to Qu.)

Quoted 5 lines · Qu Wenruo

Considering you have some metadata space left, I believe you can free enough space by deleting files (aka, moving it to other filesystems)

Thanks,
Qu

Hi Qu,

Quoted 7 lines

Thanks for that. You say I should move some files to other filesystems, but that's really the nub of my problem - the filesystem is marked as read-only. Am I Ok to do what I mentioned previously:

Quoted 3 lines

1) Unmount the filesystem.
2) Remount it as R/W
3) Move data to the external disk

If that is all good, would I need to do anything else or would the BTRFS system sort itself out correctly?

With enough unallocated space, Btrfs will be OK. Read below for more details on why/how...

Quoted 35 lines

Thanks for your attention,

Spencer

PS. The output form the 'btrfs fi usage /data' command you requested is as follows (run as root to get everything):

Overall:

    Device size:		  10.92TiB
    Device allocated:		  10.92TiB
    Device unallocated:		   1.00MiB
    Device missing:		     0.00B
    Device slack:		     0.00B
    Used:			  10.90TiB
    Free (estimated):		  15.26GiB	(min: 15.26GiB)
    Free (statfs, df):		  15.26GiB
    Data ratio:			      1.00
    Metadata ratio:		      2.00
    Global reserve:		 512.00MiB	(used: 0.00B)
    Multiple profiles:		       yes	(metadata, system)

Data,RAID0: Size:10.87TiB, Used:10.86TiB (99.86%)
/dev/mapper/data1 5.44TiB
/dev/mapper/data2 5.44TiB

Metadata,single: Size:8.00MiB, Used:0.00B (0.00%)
/dev/mapper/data1 8.00MiB

Metadata,RAID1: Size:23.00GiB, Used:21.39GiB (93.00%)
/dev/mapper/data1 23.00GiB
/dev/mapper/data2 23.00GiB

System,single: Size:4.00MiB, Used:0.00B (0.00%)
/dev/mapper/data1 4.00MiB

Quoted 7 lines

System,RAID1: Size:8.00MiB, Used:784.00KiB (9.57%)
/dev/mapper/data1 8.00MiB
/dev/mapper/data2 8.00MiB

Unallocated:

   /dev/mapper/data1	     0.00B
   /dev/mapper/data2	   1.00MiB

Btrfs uses a multi stage allocator. The first stage allocates large regions of space known as chunks for specific types of data, then the second stage allocates blocks like a regular (old-fashioned) filesystem within these larger regions.

In your case, btrfs needed to allocate another metadata chunk, but as you see, there is no unallocated space available. Btrfs went read-only to protect itself from damage.

Balancing means Btrfs moved data between chunks so that it can free them. It means that if there are two chunks with 50% usage, Btrfs can compact the data into one chunk and free the other, increasing the unallocated space that can be used for new allocations as needed.

It might be good to schedule a limited data balance at regular intervals to ensure there are always a few unallocated gigabytes.

I wrote a little about it on my wiki https://wiki.tnonline.net/w/Btrfs/ENOSPC and https://wiki.tnonline.net/w/Btrfs/Balance

Regards,
Forza