From c427ff934a4795acbf3fd1709763ab47cb5b18f5 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 14 Sep 2023 20:06:06 +0200 Subject: [PATCH] Switch from BIOS and GRUB to UEFI and systemd-boot for Proxmox VMs --- config/nixos-generators/proxmox.nix | 4 +++- config/proxmox-vm/boot.nix | 16 +++++++++------- config/proxmox-vm/storage.nix | 5 +++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/config/nixos-generators/proxmox.nix b/config/nixos-generators/proxmox.nix index ff42fb4..e8cbc85 100644 --- a/config/nixos-generators/proxmox.nix +++ b/config/nixos-generators/proxmox.nix @@ -2,6 +2,7 @@ # - https://github.com/NixOS/nixpkgs/blob/069de7d3deafab651fd627c8f6d7e4c7b33087a2/nixos/modules/virtualisation/proxmox-image.nix#L6 # - https://git.grzb.de/yuri/nix-infra/-/blob/aa38daeea59f2ca12b7e591de6f8b61565780c48/configuration/nixos-generators/default.nix#L13 # - https://git.grzb.de/yuri/nix-infra/-/blob/aa38daeea59f2ca12b7e591de6f8b61565780c48/flake.nix#L39 +# - https://pve.proxmox.com/wiki/Manual:_qm.conf { config, pkgs, ... }: @@ -12,11 +13,12 @@ cores = 2; memory = 512; virtio0 = "rpool-data:vm-9999-disk-0,discard=on"; - bios = "seabios"; + bios = "ovmf"; net0 = "virtio=00:00:00:00:00:00,bridge=vmbr0,firewall=1,tag=999"; }; qemuExtraConf = { cpu = "cputype=host,flags=+aes"; + machine = "q35"; template = 1; }; }; diff --git a/config/proxmox-vm/boot.nix b/config/proxmox-vm/boot.nix index ccf6cb0..ca217c5 100644 --- a/config/proxmox-vm/boot.nix +++ b/config/proxmox-vm/boot.nix @@ -2,8 +2,9 @@ # Sources for this configuration: # - a generated NixOS 23.05 configuration # - https://github.com/NixOS/nixpkgs/blob/069de7d3deafab651fd627c8f6d7e4c7b33087a2/nixos/modules/virtualisation/proxmox-image.nix#L241 +# - https://nixos.org/manual/nixos/stable/#sec-installation-manual-installing -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: { boot = { @@ -12,19 +13,20 @@ # Not specified here: # - boot.kernelModules # - boot.extraModulePackages - # Please specify as needed. - + # Please specify as needed elsewhere. + # Grow the root partition on boot. growPartition = true; kernelParams = [ "console=ttyS0" ]; - loader.grub = { + loader.systemd-boot = { enable = true; - # TODO: Can we use "/dev/disk/by-label/nixos" here? - device = "/dev/vda"; + editor = false; }; - loader.timeout = 0; + loader.efi.efiSysMountPoint = "/boot"; + + loader.timeout = lib.mkForce 2; }; } diff --git a/config/proxmox-vm/storage.nix b/config/proxmox-vm/storage.nix index 6748768..0342bcf 100644 --- a/config/proxmox-vm/storage.nix +++ b/config/proxmox-vm/storage.nix @@ -12,6 +12,11 @@ fsType = "ext4"; }; + fileSystems."/boot" = { + device = "/dev/disk/by-label/ESP"; + fsType = "vfat"; + }; + # Not specified here: # - swapDevices # If needed, manually specify it elsewhere.