How can I add the NVMe modules to my install disk image?

I’ve recently got a laptop which only has an NVMe drive, and I’d like to install NixOS on it.

Unfortunately, my disk isn’t being mounted when I boot into the live image (minimal or plasma).
When I check /dev/disk, there are no disks there.
When I modprobe -c | grep -i nvme, there’s no NVMe modules loaded

After a while of futzing around, I tried the Debian live image, and I could mount my disk there, and there are nvme modules loaded according to modprobe.

It’s not conclusive (perhaps there’s a deeper issue?), but it seems to be that the lack of the nvme module on the NixOS live image is the issue. (Except that googling does show me some people have succesfullly installed on NVMe disks…)

How could I be sure that the issue is NVMe?
If the issue is NVMe, how can I add that module to my live disk?

I have nixos installed on a nvme disk, and there were no extra hurdles, things just worked out of the box (but this was a desktop pc, not a laptop).

I have "nvme" in boot.initrd.availableKernelModules, I think that is definitely required, but maybe there is another issue if the live cd can’t detect/load your disk (or there is not, and you just need to do it manually in your case).

1 Like

+1 @futile; I just completed an install yesterday with an old install ISO and it recognized and installed to my nvme drives fine. (I did have to make sure it was in availablelKernelModules from the hardware-config for it to boot.)

If you did nixos-generate-config while the nvme was used. It should also add the related entry to your /etc/nixos/hardware-configuration.nix

for example, mine:

  # /etc/nixos/hardware-configuration.nix
  boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "sd_mod" "sr_mod" ];

Did you try to manually load nvme with modprobe nvme? Does the device show up in lscpi? If so you can also check with lpci -vv if it is bound to the NVME kernel driver correctly. Except for some quirks NVME is actually a well-standardized protocol with little differences between different devices.

I used the ‘default’? minimal iso for 20.09, and it failed at boot stage 1.

I couldn’t load nvme with modprobe, nor did I see any modules under /lib/modules that looked like they were for nvme (which is why I was wondering whether they were missing from the install image).

Based on some of these replies, should I have created my own image to install from?

The iso itself failed? what hardware are you using for the install disk? This is more likely that the hardware device driver wasn’t available for the install disk.

nvme should only be needed if the root filesystem was on an nvme device, and stage1 wanted to mount the filesystem from the nvme device. This is unlikely to be true if you’re still installing nixos.

1 Like

I didn’t have any /dev/nvmeX devices, and the symlink for /dev/root was broken (it went to /dev/disk/$something) which is why I thought nvme was related.

I was doing the installation from a micro sd card, and a fairly old one at that.
I have a new sdcard arriving, so I’ll try again when that arrives

If you have a usb device, all usb drivers should be available. If not, then you may need to build your own install image with the sdhci_pci kernel module added.

EDIT: to build your own image:

# iso.nix
# This module defines a small NixOS installation CD.  It does not
# contain any graphical stuff.
{config, pkgs, ...}:
  imports = [

    # Provide an initial copy of the NixOS channel so that the user
    # doesn't need to run "nix-channel --update" first.

  boot.initrd.availableKernelModules = [ "sdhci_pci" ];

to build:

nix-build '<nixpkgs/nixos>' -A -I nixos-config=iso.nix

Should produce an iso image in the local directory ./result/...


You should be able to use the base installation cd after nixos/all-hardware: add sdcard support by jonringer · Pull Request #122902 · NixOS/nixpkgs · GitHub gets merged


As another PR was merged as a solution, I think this is the PR to watch now (please correct me if I got that wrong!): [20.09] nixos/modules: add "sdhci_pci" to availableKernelModules by jonringer · Pull Request #122905 · NixOS/nixpkgs · GitHub

Once this is merged the fix will be present in release-20.09, and I guess that means it will also be present in the live-image on the website (or will it have to go from release-20.09 to nixos-20.09 as well before the image is built?).

Just if it’s not clear: The solution by @jonringer should also work in the meantime, as it does the exact same thing, just “by hand”, so if you have a linux machine you can install nix on you don’t have to wait until you can install :slight_smile: Or, I guess, alternatively you could “just” use an usb stick, which should work out-of-the-box already.


Thank you all for your help so far.

I followed @jonringer 's instructions, and built a local iso. I wrote it to a fresh SD card with dd. I mounted the iso, and had a quick poke around, and everything looked ok, as far as I can tell.

I then booted from the sdcard again, and unfortunately, I am still seeing the same failure , ie /dev/root is a symlink to /dev/disk/by-label/nixos-minimal-20.09-x86_64, and there is no /dev/disk directory

modprobe -c | grep -i sdhci shows me that the sdhci module has loaded

If you want to wait a little while, my PR should propagate through, and the new installer image should be available soon.

But @samueldr would probably be able to better help you

Kernel modules are actually here: /run/booted-system/kernel-modules/lib/modules/$(uname -r)
not in /lib/modules.