mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-14 13:39:15 +03:00
nixos/qemu-vm: add option for a separate boot partition on BIOS
This patch adds the option `virtualisation.useBootPartition` which creates a separate boot partition on BIOS systems using the new `legacy+boot` partition layout type in `nixos/lib/make-disk-image.nix`.
This commit is contained in:
parent
11ed9936cc
commit
95355b4d94
1 changed files with 36 additions and 5 deletions
|
@ -62,8 +62,20 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
selectPartitionTableLayout =
|
selectPartitionTableLayout =
|
||||||
{ useEFIBoot, useDefaultFilesystems }:
|
{
|
||||||
if useDefaultFilesystems then if useEFIBoot then "efi" else "legacy" else "none";
|
useEFIBoot,
|
||||||
|
useDefaultFilesystems,
|
||||||
|
useBootPartition,
|
||||||
|
}:
|
||||||
|
if useDefaultFilesystems then
|
||||||
|
if useEFIBoot then
|
||||||
|
"efi"
|
||||||
|
else if useBootPartition then
|
||||||
|
"legacy+boot"
|
||||||
|
else
|
||||||
|
"legacy"
|
||||||
|
else
|
||||||
|
"none";
|
||||||
|
|
||||||
driveCmdline =
|
driveCmdline =
|
||||||
idx:
|
idx:
|
||||||
|
@ -337,7 +349,9 @@ let
|
||||||
format = "qcow2";
|
format = "qcow2";
|
||||||
onlyNixStore = false;
|
onlyNixStore = false;
|
||||||
label = rootFilesystemLabel;
|
label = rootFilesystemLabel;
|
||||||
partitionTableType = selectPartitionTableLayout { inherit (cfg) useDefaultFilesystems useEFIBoot; };
|
partitionTableType = selectPartitionTableLayout {
|
||||||
|
inherit (cfg) useBootPartition useDefaultFilesystems useEFIBoot;
|
||||||
|
};
|
||||||
installBootLoader = cfg.installBootLoader;
|
installBootLoader = cfg.installBootLoader;
|
||||||
touchEFIVars = cfg.useEFIBoot;
|
touchEFIVars = cfg.useEFIBoot;
|
||||||
diskSize = "auto";
|
diskSize = "auto";
|
||||||
|
@ -431,8 +445,17 @@ in
|
||||||
|
|
||||||
virtualisation.bootPartition = mkOption {
|
virtualisation.bootPartition = mkOption {
|
||||||
type = types.nullOr types.path;
|
type = types.nullOr types.path;
|
||||||
default = if cfg.useEFIBoot then "/dev/disk/by-label/${espFilesystemLabel}" else null;
|
default =
|
||||||
defaultText = literalExpression ''if cfg.useEFIBoot then "/dev/disk/by-label/${espFilesystemLabel}" else null'';
|
if cfg.useEFIBoot then
|
||||||
|
"/dev/disk/by-label/${espFilesystemLabel}"
|
||||||
|
else if cfg.useBootPartition then
|
||||||
|
"/dev/disk/by-label/BOOT"
|
||||||
|
else
|
||||||
|
null;
|
||||||
|
defaultText = literalExpression ''
|
||||||
|
if cfg.useEFIBoot then "/dev/disk/by-label/${espFilesystemLabel}"
|
||||||
|
else if cfg.useBootPartition then "/dev/disk/by-label/BOOT"
|
||||||
|
else null'';
|
||||||
example = "/dev/disk/by-label/esp";
|
example = "/dev/disk/by-label/esp";
|
||||||
description = ''
|
description = ''
|
||||||
The path (inside the VM) to the device containing the EFI System Partition (ESP).
|
The path (inside the VM) to the device containing the EFI System Partition (ESP).
|
||||||
|
@ -929,6 +952,14 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virtualisation.useBootPartition = mkEnableOption null // {
|
||||||
|
description = ''
|
||||||
|
If enabled for legacy MBR VMs, the VM image will have a separate boot
|
||||||
|
partition mounted at /boot.
|
||||||
|
useBootPartition is ignored if useEFIBoot == true.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
virtualisation.useEFIBoot = mkOption {
|
virtualisation.useEFIBoot = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue