Ubuntu – Adding an SSD to an existing HDD-based BTRFS filesystem

btrfsssdUbuntu

I have a BTRFS filesystem with a HDDs of various sizes. I thought adding an SSD might allow BTRFS to use it as a caching layer or just another much-faster drive (the docs are a little sparse on this: https://btrfs.wiki.kernel.org/index.php/FAQ#Is_Btrfs_optimized_for_SSD.3F ). However when I run btrfs fi show /data it shows the SSD as unused:

Total devices 8 FS bytes used 4.29TiB

// SSD moved to the top of the list for easier reading
devid    9 size 223.57GiB used 0.00B path /dev/sda
devid    1 size 2.73TiB used 1.28TiB path /dev/sdb1
devid    5 size 0.00B used 356.00GiB path /dev/sdi1
devid    6 size 1.82TiB used 379.00GiB path /dev/sde1
devid    7 size 4.55TiB used 3.09TiB path /dev/sdh
devid    8 size 3.64TiB used 2.19TiB path /dev/sdc
devid   10 size 2.73TiB used 1.28TiB path /dev/sdf
devid   11 size 1.82TiB used 24.00GiB path /dev/sdg

Also if I run btrfs device usage /data it also reports the SSD as unused:

/dev/sda, ID: 9
Device size:           223.57GiB
Unallocated:           223.57GiB

So I thought I'd check my fstab mount options:

# Mount BTRFS array
UUID=587d228b-5dc3-44e6-b9d9-83df5682d50d       /data   btrfs   defaults,noatime,space_cache,discard    0       0

As far as I can tell these are all pretty standard.

Is this normal, how can I tell if BTRFS is actually using the drive at all? (I may be totally mistaken and BTRFS might not even support this use case at all)

Best Answer

Just adding a device to a BTRFS pool doesn't automatically move any data to it, you have to write new data to the pool and the balancer will decide which device it puts the data on.
The next chunk is very likely to be created on a newly added device though since it's 0% allocated (the balancer tries to fill up all devices equally).

If you want to make already written data go through the balancer again, you need to use the btrfs balance command.

All data that is put on the SSD will be faster than the data on the HDDs but there is no speed aware balancing in place, so which data is fast and which isn't is pretty much random and cannot be manually controlled either.

Related Question