BTRFS single data FS still striped

btrfsraid0

UPDATE

So after a long time of research in the official documentation, I found out that btrfs allocates space in chunks each 1Gb and when using single mode, these chunks are allocated on the disk with currently the most unallocated space.
Therefore the data gets striped between the different disks and as I see it, losing one disk would result in a complete loss of files larger than 1Gb.

My conclusion is, that the only benefit of using single mode over a raid0 (also supported by btrfs) is the possibility the use different sized disks. Any other thoughts?

Original Post

So I created a btrfs filesystem consisting of 3 devices with data mode single using the following command:

sudo mkfs.btrfs -f -d single /dev/sdb7 /dev/sdb8 /dev/sdb9

Then I mounted the fs to the folder nonRaid and created a 10G file using

fallocate -l 10G nonRaid/example

I understand the difference between using raid0 and single is, that raid0 will stripe the data accross the 3 devices in my case and using single mode the data will not be striped but saved as a whole chunk on the disk as NTFS would do. Do I understand this correctly?

If so, how can one explain that when using

btrfs filesystem usage nonRaid/

it shows me the following output:

Overall:
Device size:                  59.98GiB
Device allocated:             13.02GiB
Device unallocated:           46.96GiB
Device missing:                  0.00B
Used:                         10.05GiB
Free (estimated):             47.91GiB      (min: 24.43GiB)
Data ratio:                       1.00
Metadata ratio:                   2.00
Global reserve:               16.00MiB      (used: 0.00B)

Data,single: Size:11.01GiB, Used:10.05GiB
/dev/sdb7       3.01GiB  <---
/dev/sdb8       5.00GiB  <---
/dev/sdb9       3.00GiB  <---

The 10G data is split accross the 3 devices, tho not as evenly as it would be using raid0.
Does btrfs not support a mode which fills up entire disks after another?
Because this striping would still mean that if e.g. /dev/sdb8 would irrecoverably fail, my whole data of the whole filesystem would be gone – right?

Best Answer

I know this is a bit old question, though I have found it during my research on the same track. There's a pretty thorough explanation from Hugo Mills on the btrfs-kernel mailing list (https://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg44523.html).

tl;dr; btrfs stores the files in 1GB chunks and allocated them equally to the available free space on each drive. So, "with equal-sized devices, the first 1 GiB will go on the first device, the second 1 GiB on the second device, and so on."