Why does btrfs allow to create a raid1 with mismatched drives

btrfsmirrorraidraid1

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.

Best Answer

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.

Related Question