From 40458f49ebada72ccd8c62ac16d1a9b5c4345b80 Mon Sep 17 00:00:00 2001 From: Soispha Date: Sat, 8 Jul 2023 11:16:40 +0200 Subject: Fix(system/disks): Change partitioning scheme to support gpt/bios boot --- hosts/server1/hardware.nix | 1 + system/disks/default.nix | 62 ++++++++++++++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/hosts/server1/hardware.nix b/hosts/server1/hardware.nix index 9fabafe..6086362 100644 --- a/hosts/server1/hardware.nix +++ b/hosts/server1/hardware.nix @@ -3,6 +3,7 @@ (modulesPath + "/profiles/qemu-guest.nix") (modulesPath + "/profiles/headless.nix") ]; + # FIXME: The name of the grub device depends on the disko settings boot.loader.grub.device = "/dev/vda"; boot.initrd.availableKernelModules = ["ata_piix" "uhci_hcd" "virtio_pci" "sr_mod" "virtio_blk"]; boot.initrd.kernelModules = []; diff --git a/system/disks/default.nix b/system/disks/default.nix index 24898fe..5453426 100644 --- a/system/disks/default.nix +++ b/system/disks/default.nix @@ -7,7 +7,6 @@ with lib; let cfg = config.system.disks; defaultMountOptions = ["compress-force=zstd:15"]; in { - options.system.disks = { disk = mkOption { type = lib.types.path; @@ -21,26 +20,47 @@ in { disk.main = { device = cfg.disk; content = { - type = "btrfs"; - extraArgs = ["-f" "--label nixos"]; # f: Override existing partitions - subvolumes = { - "nix" = { - mountpoint = "/nix"; - mountOptions = defaultMountOptions; - }; - "persistent-storage" = { - mountpoint = "/srv"; - mountOptions = defaultMountOptions; - }; - "persistent-storage@snapshots" = { - mountpoint = "/srv/.snapshots"; - mountOptions = defaultMountOptions; - }; - "boot" = { - mountpoint = "/boot"; - mountOptions = defaultMountOptions; - }; - }; + type = "table"; + format = "gpt"; + partitions = [ + { + name = "boot"; + start = "0"; + end = "1M"; + part-type = "primary"; + flags = ["bios_grub"]; + } + { + name = "root"; + # leave space for the grub aka BIOS boot + start = "1M"; + end = "100%"; + part-type = "primary"; + bootable = true; + content = { + type = "btrfs"; + extraArgs = ["-f" "--label nixos"]; # f: Override existing partitions + subvolumes = { + "nix" = { + mountpoint = "/nix"; + mountOptions = defaultMountOptions; + }; + "persistent-storage" = { + mountpoint = "/srv"; + mountOptions = defaultMountOptions; + }; + "persistent-storage@snapshots" = { + mountpoint = "/srv/.snapshots"; + mountOptions = defaultMountOptions; + }; + "boot" = { + mountpoint = "/boot"; + mountOptions = defaultMountOptions; + }; + }; + }; + } + ]; }; }; nodev = { -- cgit 1.4.1