disko icon indicating copy to clipboard operation
disko copied to clipboard

top-level option for btrfs multi-device volume

Open montchr opened this issue 1 year ago • 5 comments

Context

I am looking to implement a layout composed of two NVMe devices, similar to the following example:

https://github.com/tfc/nixos-anywhere-example/blob/fd710be5255931a64a9efb9c15c9b36e6011e7b4/two-raids-on-two-disks.nix

In contrast to that example, I would like to use BTRFS' native support for multi-device volumes instead of using mdadm:

mkfs.btrfs --force \
  --label nixos \
  --data single \
  --metadata raid1 \
  "${NVME01}p3" \
  "${NVME02}p3"

Problem

I would expect to be able to configure subvolumes for a multi-device BTRFS volume at disko.devices.btrfs (or some more-fitting name) in the same way that other volume-like domains e.g. mdadm, zpool do:

https://github.com/nix-community/disko/blob/5d9f362aecd7a4c2e8a3bf2afddb49051988cab9/lib/default.nix#L306-L334

While similar to #99, this problem pertains more to first-class BTRFS support with a top-level option. Such an option was suggested in https://github.com/nix-community/disko/issues/99#issuecomment-1368275363 but the issue was closed shortly thereafter.

Question

Is it currently possible to configure multi-device BTRFS subvolumes using Disko?

montchr avatar Jun 10 '23 17:06 montchr

No this is not implemented just now, but feel free to implement it. @Lassulus might have some guidelines on how to do this.

Mic92 avatar Jun 11 '23 02:06 Mic92

Pretty much the same feature is also supported for zfs user space tools, but Disko doesn't implement it for zfs neither so far.

phaer avatar Jun 11 '23 06:06 phaer

Well, you can great raids with zfs: https://github.com/nix-community/disko/blob/5d9f362aecd7a4c2e8a3bf2afddb49051988cab9/example/zfs.nix#L58

Mic92 avatar Jun 11 '23 16:06 Mic92

Well, you can great raids with zfs:

Yes, that's what I am talking about here. But with standard zfs tools you can i.e. create a mirror (or raidz) on N disks and add a cache on a faster SSD, all in the same command. I.e.

zpool create my-pool raidz /dev/by-name/disk-1 /dev/by-name/disk-2 /dev/by-name/disk-3 [..] /dev/by-name/disk-N cache /dev/by-name/ssd-1

I believe this isn't supported by disko at the moment and seems similar to the btrfs feature in terms of nixos module code? Pretty sure there's a thread where @Lassulus and me've talked about this already but i can't find that atm.

phaer avatar Jun 12 '23 10:06 phaer

No this is not implemented just now, but feel free to implement it. @Lassulus might have some guidelines on how to do this.

@Lassulus, after the holidays may I please have guidelines for this? Assuming ignore or deny raid 5/6.

Currently I think it may already be possible to do this by using extraArgs and mountOptions to achieve something like mkfs.btrfs -m raid1 -d raid1 with disko btrfs config. May be mistaken though.

andar1an avatar Dec 24 '23 18:12 andar1an