nix-community / disko

Declarative disk partitioning and formatting using nix [maintainers=@Lassulus @Enzime @iFreilicht]
MIT License
1.88k stars 199 forks source link

GRUB Mirrored boot entries with disko #572

Open Ma27 opened 8 months ago

Ma27 commented 8 months ago

Given a Hetzner AX41 NVMe (two SSDs, MBR / legacy boot required) with a mirrored zpool (not part of the example):

{
  disko.devices.disk.nvme0n1 = {
    type = "disk";
    device = "/dev/nvme0n1";
    content = {
      type = "gpt";
      partitions = [
        { name = "bios0";
          type = "EF02";
          start = "1024";
          end = "2047";
        }
        { name = "boot0";
          type = "EF00";
          start = "1M";
          size = "512M";
          content = {
            type = "filesystem";
            format = "vfat";
            mountpoint = "/boot";
          };
        }
        # ...
      ];
    };
  };
  disko.devices.disk.nvme1n1 = {
    type = "disk";
    device = "/dev/nvme1n1";
    content = {
      type = "gpt";
      partitions = [
        { name = "bios1";
          type = "EF02";
          start = "1024";
          end = "2047";
        }
        { name = "boot1";
          type = "EF00";
          start = "1M";
          size = "512M";
          content = {
            type = "filesystem";
            format = "vfat";
            mountpoint = "/boot-fallback";
          };
        }
        # ...
      ];
    };
  };
}

This gives me a single entry in boot.loader.grub.mirroredBoots with devices containing both /dev/nvme0n1 and /dev/nvme1n1.

What I need though is

{
  boot.loader.grub.mirroredBoots = [
    { devices = [ "/dev/nvme0n1" ];
      path = "/boot";
      }
    { devices = [ "/dev/nvme1n1" ];
      path = "/boot-fallback";
    }
  ];
}

My workaround was to use mkForce on mirroredBoots. However I'm wondering if there's a better way to achieve that. Or am I holding it wrong?

Mic92 commented 8 months ago

Looks very similar to what I had to do: https://github.com/Mic92/dotfiles/blob/b2ff14454465c10d00c4239eea0785583ddf9a35/nixos/eve/modules/disko.nix#L39

I didn't had to use mkForce though.

Mic92 commented 8 months ago

Btw. You can also enable UEFI on most hetzner machines by ordering the KVM console once.

iFreilicht commented 1 month ago

I would consider this a bug, though I'm not sure if it's disko's fault or nixpkgs'. In any case, it's not the behavior you would expect when creating multiple boot partitions.