Skip to content

Commit

Permalink
nixos/stage-1: create initramfs /lib at build time
Browse files Browse the repository at this point in the history
Modules built in to the kernel can attempt to load firmware before
init is started.  To guarantee the firmware is accessible to them
where they expect, /lib has to exist in the initramfs — it can't be
created later by init, because by that point the module may already
have tried and given up.
  • Loading branch information
alyssais committed Nov 6, 2023
1 parent e55c73a commit d9105c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 0 additions & 3 deletions nixos/modules/system/boot/stage-1-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,6 @@ done
@setHostId@

# Load the required kernel modules.
mkdir -p /lib
ln -s @modulesClosure@/lib/modules /lib/modules
ln -s @modulesClosure@/lib/firmware /lib/firmware
echo @extraUtils@/bin/modprobe > /proc/sys/kernel/modprobe
for i in @kernelModules@; do
info "loading module $(basename $i)..."
Expand Down
5 changes: 4 additions & 1 deletion nixos/modules/system/boot/stage-1.nix
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ let
${pkgs.buildPackages.busybox}/bin/ash -n $target
'';

inherit linkUnits udevRules extraUtils modulesClosure;
inherit linkUnits udevRules extraUtils;

inherit (config.boot) resumeDevice;

Expand Down Expand Up @@ -349,6 +349,9 @@ let
[ { object = bootStage1;
symlink = "/init";
}
{ object = "${modulesClosure}/lib";
symlink = "/lib";
}
{ object = pkgs.runCommand "initrd-kmod-blacklist-ubuntu" {
src = "${pkgs.kmod-blacklist-ubuntu}/modprobe.conf";
preferLocalBuild = true;
Expand Down

0 comments on commit d9105c2

Please sign in to comment.