1. 12
  1. 5

    I was surprised to learn recently that Synology (a popular proprietary Linux-based NAS) switched to using Btrfs inside LVM in their newer releases. That caused me to drive back in and see what the status of Btrfs in general was.

    I came away deciding it’s a mixed bag. None of the RAID levels Btrfs supports work quite as expected, and there are warnings against using them in production. But using Btrfs within LVM does turn out to be quite reasonable as a compromise, giving you things like copy-on-write and more modern file structures without getting into the oddities of Btrfs snapshots and RAID.

    I’ll keep hoping that Btrfs does eventually get there as a genuine ZFS alternative, but I really appreciate guides like this for showing how to set it up even on little Alpine boxes where it can be very useful as-is

    1. 3

      This is because BTRFS does not know about the drives yet when the filesystems are mounted

      Does anyone know why this happens? I haven’t experienced it on Ubuntu / CentOS / Fedora. Even mounting btrfs from a file just works without extra steps there. Why does Alpine need an explicit scan?

      1. 1

        The btrfs-packages for distros like Ubuntu/Fedora install an init-script that does this. Alpine isn’t “there” yet, so you have to manually add it.

        1. 1

          Do you know where specifically? In Ubuntu for example I can only find 64-btrfs-dm.rules which I don’t believe will kick in after running mkfs. And I’m sure you can mkfs, then mount without scanning.

          1. 2

            I imagine it is just that. The systemd-udevd vendored rules and the btrfs built-in, in udevd, remove the need to use the btrfs-progs btrfs device scan sub command.

            I only dug about this deep: https://github.com/systemd/systemd/blob/main/src/udev/udev-builtin-btrfs.c#L37 https://github.com/kdave/btrfs-progs/blob/master/common/device-scan.c#L233

            I’m assuming the device scan ioctl probably does most of what udevd would know from running its own filesystem detection built-ins or utilities. I checked /usr/include/linux/btrfs.h but the documentation in the header is very sparse. I guess the next step would be poking through the kernel to confirm the ioctl behavior is what I think it is. Maybe I’ll update this post if I get to it.

            1. 1

              Ok so this makes sense - mkfs.btrfs does the scan ioctl call itself on the device when it’s finished: https://github.com/kdave/btrfs-progs/blob/c0ad9bde429196db7e8710ea1abfab7a2bca2e43/mkfs/main.c#L1657