btrfs Playbook
My commonly used Btrfs commands. I enjoy using Btrfs as it is
compatible with Linux kernel GPL licensing. It’s mainline
supported, simple to manage, and it provides me much of the same
functionality I get with zfs.
Single Device
Format a single drive with Btrfs.
mkfs.btrfs /dev/sdX1
That device can be mounted somewhere like
/mnt/my-data.
Two Devices
Add a single device to an existing Btrfs filesystem.
btrfs device add -f /dev/sdX2 /mnt/my-data
The filesystem will grow by the size of the new device. It is now a filesystem consisting of two devices.
Two Devices -> Mirror
Balance a Btrfs filesytem with two devices using
raid1. Notably, this uses --bg so the
task is backgrounded.
btrfs balance start -dconvert=raid1 -mconvert=raid1 --bg /mnt/my-data
Balance Status
Check the balance status of a filesystem.
btrfs balance status -v /mnt/my-data
Sub-Volume
Create a sub-volume.
btrfs subvolume create /mnt/my-data/@my-subvolume
fstab Sub-Volume
/dev/sdX1 /mnt/my-subvolume btrfs defaults,subvol=@my-subvolume 0 2
Two Devices -> Three Devices
Add a third device to a btrfs filesystem.
btrfs device add /dev/sdX3 /mnt/my-data
Three Devices -> Mirror
btrfs balance start --bg -mconvert=raid1c3 -dconvert=raid1c3 /mnt/my-data
Check Filesystem Stats
btrfs device stats /mnt/my-data