Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

top-level option for btrfs multi-device volume #261

Open
montchr opened this issue Jun 10, 2023 · 6 comments
Open

top-level option for btrfs multi-device volume #261

montchr opened this issue Jun 10, 2023 · 6 comments
Labels
contributions welcome There's nothing left to discuss, feel free to submit a PR for this! enhancement New feature or request

Comments

@montchr
Copy link

montchr commented Jun 10, 2023

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:

disko/lib/default.nix

Lines 306 to 334 in 5d9f362

devices = lib.types.submodule {
options = {
disk = lib.mkOption {
type = lib.types.attrsOf diskoLib.types.disk;
default = { };
description = "Block device";
};
mdadm = lib.mkOption {
type = lib.types.attrsOf diskoLib.types.mdadm;
default = { };
description = "mdadm device";
};
zpool = lib.mkOption {
type = lib.types.attrsOf diskoLib.types.zpool;
default = { };
description = "ZFS pool device";
};
lvm_vg = lib.mkOption {
type = lib.types.attrsOf diskoLib.types.lvm_vg;
default = { };
description = "LVM VG device";
};
nodev = lib.mkOption {
type = lib.types.attrsOf diskoLib.types.nodev;
default = { };
description = "A non-block device";
};
};
};

While similar to #99, this problem pertains more to first-class BTRFS support with a top-level option. Such an option was suggested in #99 (comment) but the issue was closed shortly thereafter.

Question

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

@montchr montchr changed the title top-level option for configuring btrfs multi-device volume btrfs multi-device volume support Jun 10, 2023
@montchr montchr changed the title btrfs multi-device volume support top-level option for btrfs multi-device volume Jun 10, 2023
@Mic92
Copy link
Member

Mic92 commented Jun 11, 2023

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

@phaer
Copy link
Member

phaer commented Jun 11, 2023

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

@Mic92
Copy link
Member

Mic92 commented Jun 11, 2023

Well, you can great raids with zfs:

mode = "mirror";

@phaer
Copy link
Member

phaer commented Jun 12, 2023

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.

@andar1an
Copy link

andar1an commented Dec 24, 2023

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.

@iFreilicht
Copy link
Contributor

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 believe this isn't supported by disko at the moment and seems similar to the btrfs feature in terms of nixos module code?

It is since #723. I would say an implementation for btrfs should follow a similar structure.

@iFreilicht iFreilicht added enhancement New feature or request contributions welcome There's nothing left to discuss, feel free to submit a PR for this! labels Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions welcome There's nothing left to discuss, feel free to submit a PR for this! enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants