nixos/boot-media: soft-force entire fs layout

https://github.com/NixOS/nixpkgs/pull/131760 was made to avo
a speicific configuration conflict that errored out for multiple definitions of "/" when the installer where overlayed
on any existing host configuration.

---

Problem 1: It turns out that in also other mountpoints can coflict.

Solution 1: use `mkOverride 60` for all mountpoints (even for the ones unlikely causing confilct for consistency sake)

---

Problem 2: It turns out that on an installation media for a fresh machine (before formatting), we usually don't have any devices yet formatted. However defining for example `fileSystems.<nme>.device = "/dev/disk/by-label/...", in newer versions of nixos, seems to make the system startup fail. Similarily waiting for a non-existent swap device does not make the startup fail, but has a 1:30 min timeout.

Solution 2: For an installation medium, soft-override ("unless users know what they are doing") the entire `fileSystems` and `swapDevices` definitions.
launchpad/nixpkgs/master
David Arnold 3 years ago
parent 8ff76e34e0
commit 2af2d3146d
No known key found for this signature in database
GPG Key ID: AB15A6AF1101390D
  1. 6
      nixos/modules/installer/cd-dvd/installation-cd-base.nix
  2. 101
      nixos/modules/installer/cd-dvd/iso-image.nix
  3. 18
      nixos/modules/installer/netboot/netboot.nix

@ -30,6 +30,12 @@ with lib;
# Add Memtest86+ to the CD.
boot.loader.grub.memtest86.enable = true;
# On a fresh machine, before formatting, an installation
# media cannot assume an existing file system layout such
# as might be defined by the encapsulated host config.
swapDevices = mkOverride 60 [ ];
fileSystems = mkOverride 60 config.lib.isoFileSystems;
boot.postBootCommands = ''
for o in $(</proc/cmdline); do
case "$o" in

@ -614,6 +614,58 @@ in
};
};
# store them in lib so we can set the same fileSystems with a
# higher prio on installation media
# This module is often over-layed onto an existing host config
# that defines `fileSystems`. We use mkOverride 60 to override
# standard values, but at the same time leave room for mkForce
# values targeted at the image build.
config.lib.isoFileSystems = {
"/" = mkOverride 60
{
fsType = "tmpfs";
options = [ "mode=0755" ];
};
# Note that /dev/root is a symlink to the actual root device
# specified on the kernel command line, created in the stage 1
# init script.
"/iso" = mkOverride 60
{ device = "/dev/root";
neededForBoot = true;
noCheck = true;
};
# In stage 1, mount a tmpfs on top of /nix/store (the squashfs
# image) to make this a live CD.
"/nix/.ro-store" = mkOverride 60
{ fsType = "squashfs";
device = "/iso/nix-store.squashfs";
options = [ "loop" ];
neededForBoot = true;
};
"/nix/.rw-store" = mkOverride 60
{ fsType = "tmpfs";
options = [ "mode=0755" ];
neededForBoot = true;
};
"/nix/store" = mkOverride 60
{ fsType = "overlay";
device = "overlay";
options = [
"lowerdir=/nix/.ro-store"
"upperdir=/nix/.rw-store/store"
"workdir=/nix/.rw-store/work"
];
depends = [
"/nix/.ro-store"
"/nix/.rw-store/store"
"/nix/.rw-store/work"
];
};
};
config = {
assertions = [
@ -653,54 +705,7 @@ in
"boot.shell_on_fail"
];
fileSystems."/" =
# This module is often over-layed onto an existing host config
# that defines `/`. We use mkOverride 60 to override standard
# values, but at the same time leave room for mkForce values
# targeted at the image build.
{ fsType = mkOverride 60 "tmpfs";
options = [ "mode=0755" ];
};
# Note that /dev/root is a symlink to the actual root device
# specified on the kernel command line, created in the stage 1
# init script.
fileSystems."/iso" =
{ device = "/dev/root";
neededForBoot = true;
noCheck = true;
};
# In stage 1, mount a tmpfs on top of /nix/store (the squashfs
# image) to make this a live CD.
fileSystems."/nix/.ro-store" =
{ fsType = "squashfs";
device = "/iso/nix-store.squashfs";
options = [ "loop" ];
neededForBoot = true;
};
fileSystems."/nix/.rw-store" =
{ fsType = "tmpfs";
options = [ "mode=0755" ];
neededForBoot = true;
};
fileSystems."/nix/store" =
{ fsType = "overlay";
device = "overlay";
options = [
"lowerdir=/nix/.ro-store"
"upperdir=/nix/.rw-store/store"
"workdir=/nix/.rw-store/work"
];
depends = [
"/nix/.ro-store"
"/nix/.rw-store/store"
"/nix/.rw-store/work"
];
};
fileSystems = config.lib.isoFileSystems;
boot.initrd.availableKernelModules = [ "squashfs" "iso9660" "uas" "overlay" ];

@ -29,31 +29,31 @@ with lib;
then []
else [ pkgs.grub2 pkgs.syslinux ]);
fileSystems."/" =
# This module is often over-layed onto an existing host config
# that defines `/`. We use mkOverride 60 to override standard
# values, but at the same time leave room for mkForce values
# targeted at the image build.
{ fsType = mkOverride 60 "tmpfs";
# This module is often over-layed onto an existing host config
# that defines `fileSystems`. We use mkOverride 60 to override
# standard values, but at the same time leave room for mkForce
# values targeted at the image build.
fileSystems."/" = mkOverride 60
{ fsType = "tmpfs";
options = [ "mode=0755" ];
};
# In stage 1, mount a tmpfs on top of /nix/store (the squashfs
# image) to make this a live CD.
fileSystems."/nix/.ro-store" =
fileSystems."/nix/.ro-store" = mkOverride 60
{ fsType = "squashfs";
device = "../nix-store.squashfs";
options = [ "loop" ];
neededForBoot = true;
};
fileSystems."/nix/.rw-store" =
fileSystems."/nix/.rw-store" = mkOverride 60
{ fsType = "tmpfs";
options = [ "mode=0755" ];
neededForBoot = true;
};
fileSystems."/nix/store" =
fileSystems."/nix/store" = mkOverride 60
{ fsType = "overlay";
device = "overlay";
options = [

Loading…
Cancel
Save