disko icon indicating copy to clipboard operation
disko copied to clipboard

`:` is not a valid character for `disko.devices.disk` attribute

Open someonewithpc opened this issue 10 months ago • 2 comments

I'm trying to define a scheme where I have mdadm RAID across two disks, with /dev/disk/by-path, and I tried to use the following:

{ lib, ... }: {
  disko.devices = {
    disk = lib.genAttrs [ "pci-0000:04:00.0-nvme-1" "pci-0000:0f:00.0-nvme-1" ] (path: {
      type = "disk";
      device = "/dev/disk/by-path/${path}";
      content = {
        type = "gpt";
        partitions = {
          ESP = {
            size = "1G";
            type = "EF00";
            content = {
              type = "mdraid";
              name = "boot";
            };
          };
          RAID = {
            size = "100%";
            content = {
              type = "mdraid";
              name = "raid";
            };
          };
        };
      };
    });

    mdadm = {
      boot = {
        type = "mdadm";
        level = 1;
        metadata = "1.0";
        content = {
          type = "filesystem";
          format = "vfat";
          mountpoint = "/boot";
          mountOptions = [ "umask=0077" ];
        };
      };

      raid = {
        type = "mdadm";
        level = 0;
        metadata = "1.0";
        content = import ../btrfs-on-luks.nix;
      };
    };
  };
}

But I get

+ mdadm --create /dev/md/boot --level=1 --raid-devices=2 --metadata=1.0 --force --homehost=any /dev/disk/by-partlabel/disk-pci-0000:04:00.0-nvme-1-ESP /dev/disk/by-partlabel/disk-pci-0000:0f:00.0-nvme-1-ESP
mdadm: cannot open /dev/disk/by-partlabel/disk-pci-0000:04:00.0-nvme-1-ESP: No such file or directory

However, with

disk = let
  paths = [ "pci-0000:04:00.0-nvme-1" "pci-0000:0f:00.0-nvme-1" ];
in lib.listToAttrs (lib.map (path: {
  name = lib.replaceStrings [":"] ["-"] path;
  value = ...;
}) paths);

It works, so it seems like : is not a valid character for the partition name, at least for mdadm.

Could there be a type error for this, or would there be a way to escape it to allow it?

someonewithpc avatar Jan 12 '25 00:01 someonewithpc

Would be good to know if sgdisk already failed with that partition name or if it just a mdadm limitation

Lassulus avatar Jan 12 '25 11:01 Lassulus

Would be good to know if sgdisk already failed with that partition name or if it just a mdadm limitation

My setup on a laptop is using by-path and not mdadm, and it works, so I think it's a limitation on mdadm. See https://codeberg.org/someonewithpc/nixos-dotfiles/src/branch/main/lithium/disko.nix#L6

someonewithpc avatar Jan 19 '25 16:01 someonewithpc