I'm creating a btrfs using

sudo mkfs.btrfs -m raid1 -d raid1 <small-disk> <large-disk> or
sudo mkfs.btrfs -m raid1 -d raid1 <large-disk> <small-disk>

it creates the fs with the size of the sum of the two disks/partitions, but

 btrfs fi df <mountpoint>

gives me RAID1 for data, system and metadata

How can this be correct?

Is there some way like mdadm's

cat /proc/mdstat

to see what btrfs is doing and to assure myself my raid1 is secure? It's not terribly important data, hence it's ok to use btrfs, but i don't want to lose it either.

  • 2
    Try creating a large file in that volume, and look at the impact on df. Haven't followed btrfs lately, but I believe their Wiki has information about how to interpret df output on btrfs. – Mat Jan 5 '12 at 9:56
  • You should use a backup if you don't want to lose data. Btrfs raid protects only against single disk errors and data rotting, not against lightning, fire etc.. – inf3rno Aug 9 '17 at 23:11

I found out the answer by asking on the mailing-list.

btrfs doesn't do RAID per-volume, but rather on a per-chunk basis. The filesystem reserves "raw" space in (p.e.) 1GB chunks. Initializing the fs with raid1 means that every time it tries to allocate a chunk, it tries to allocate a copy of this chunk on another device.

This architecture allows mixed-size devices and its future features might include per-file raid-levels.

Currently df shows you the amount of free raw space on the devices, which is the sum of all the device-sizes. Assuming the chunk-size is 1GB, writing just a 5MB file onto a raid1-btrfs will therefore decrease the raw space by 2GB. That is why btrfs includes the btrfs fi df command to give you the actual usage. This will probably be adapted in the future to show more precisely what is going on.

  • So it's more or less thin provisioning? If your disks are full, you could add more disks to the pool and just keep on going. – Gert Jan 9 '12 at 11:39
  • 1
    I'm not sure it's technically thin-provising, since btrfs takes up that space for it's chunks, but yes, you could add more disks later. – Fabian Zeindl Jan 9 '12 at 17:12
  • Elaborating a bit more, btrfs will make two copies, each in a different device. So if you have only two devices, effectively the small one is defining the space available. It makes more sense when you think of three devices, since you could fill all them e.g. if a big one is double than other two and you ended with a copy of each chunck in the big device and in one of the half-size ones. Though, I must say, I don't know the allocation policy (e.g. if it uses the more empty devices first, then it would more or less achieve this). – Álex Jan 19 '17 at 16:15
  • Nice! I already like this file system, I'll get my drives this week, I am looking forward to using btrfs. – inf3rno Aug 9 '17 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.