Failed to load kernel modules on nixos-rebuild switch and boot

Hello,

I recently installed nixos on my workstation(hardware) and I am having problems with some kernel modules failing to load either when doing nixos-rebuild switch or on booting.

[user@nixos:/nix/store]$ sudo nixos-rebuild switch --show-trace                     
[sudo] password for user: 
building Nix...
building the system configuration...
activating the configuration...
setting up /etc...
reloading user units for sddm...
reloading user units for user...
setting up tmpfiles
warning: the following units failed: systemd-modules-load.service

â—Ź systemd-modules-load.service - Load Kernel Modules
   Loaded: loaded (/nix/store/dcq8vn5xnb0hn9phzp40y8mibfssvifz-systemd-243.7/example/systemd/system/systemd-modules-load.service; enabled; vendor preset: enabled)
  Drop-In: /nix/store/46c9vdkf3x9508i3yzdc4xrmjw47qq2j-system-units/systemd-modules-load.service.d
           └─overrides.conf
   Active: failed (Result: timeout) since Wed 2020-03-25 12:23:30 CET; 24ms ago
     Docs: man:systemd-modules-load.service(8)
           man:modules-load.d(5)
  Process: 1176 ExecStart=/nix/store/dcq8vn5xnb0hn9phzp40y8mibfssvifz-systemd-243.7/lib/systemd/systemd-modules-load (code=killed, signal=TERM)
 Main PID: 1176 (code=killed, signal=TERM)
       IP: 0B in, 0B out
      CPU: 6ms

Mar 25 12:22:00 nixos systemd[1]: Starting Load Kernel Modules...
Mar 25 12:23:30 nixos systemd[1]: systemd-modules-load.service: start operation timed out. Terminating.
Mar 25 12:23:30 nixos systemd[1]: systemd-modules-load.service: Main process exited, code=killed, status=15/TERM
Mar 25 12:23:30 nixos systemd[1]: systemd-modules-load.service: Failed with result 'timeout'.
Mar 25 12:23:30 nixos systemd[1]: Failed to start Load Kernel Modules.
warning: error(s) occurred while switching to the new configuration

So to further debug this issue i tried :

[user@nixos:/nix/store]$ journalctl _PID=1176
– Logs begin at Mon 2020-03-23 16:06:41 CET, end at Wed 2020-03-25 12:23:30 CET. –
– No entries –

but unfortunately there are no logs (is there a nixos options to activate more logging for this ? )

my hardware-configuration contains the following kernel modules:

{ config, lib, pkgs, … }:

{
imports =
[ <nixpkgs/nixos/modules/installer/scan/not-detected.nix>
];

boot.initrd.availableKernelModules = [ “nvme” “xhci_pci” “ahci” “usbhid” “usb_storage” “sd_mod” ];
boot.initrd.kernelModules = ;
boot.kernelModules = [ “kvm-amd” “wl” ];
boot.extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];
…

I am looking for guidance on how to debug/fix this issue.

Thx

P.s I am running on nixos 19.09

I have the same issue and I traced it to this: https://bugzilla.kernel.org/show_bug.cgi?id=206795

Running journalctl -b gives me a kernel bug during the boot that seems to cause this timeout.

1 Like

@ndreas Thank you very much . I also have the kernel bug it’s printed during boot. And i also can see it with your provided command journalctl -b .

Originally i thought i have 2 issues (the kernel modules failing to load) and the traceback i saw during boot. But thx to you , i know now that it’s just one issue ( nice :slight_smile: ) .

Did you change your kernel version to get rid of this issue ?
I’m playing with the thought to change it back 4.19.106 as the bug creator wrote that it’s still working there. Just need to find out how to do this :smiley:

Anyways, thx for your help you saved me a lot of time troubleshooting.

I’m currently on 20.03 beta and had to downgrade to the 4.19 kernel due to some other problems so I’m going to try to go back to the 5.4 kernel. Otherwise I think I’ll wait out 4.19.110.

1 Like

/etc/nixos/configuration.nix for downgrading to 4.19.106 (requires a reboot afterwards)

boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_4_19.override {
  argsOverride = rec {
    src = pkgs.fetchurl {
          url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
          sha256 = "63c8bd76a9b282e18112f8ff9e3fd41e3d1df9f9b7248ea1a370b05a827e9cda";
    };
    version = "4.19.106";
    modDirVersion = "4.19.106";
    };
  });

taken from: Override kernel version - #5 by Alan01252

sudo nixos-rebuild switch && reboot

After that everything is fine :slight_smile:

Another possible solution would be setting boot.kernelPackages = pkgs.linuxPackages_latest; and using 5.4 on 19.09, that’s what I ended up doing.