Can't boot on host machine: Waiting for device /dev/disk/by-uuid to appear

I installed NixOS by mounting the disk and ISO-installer on a Hyper-V virtual machine. It boots well in Hyper-V, but failed in a physical machine.

Waiting for device /dev/disk/by-uuid/...... to appear.

By viewing the boot log (boot.kernelParams = ["boot.trace" "boot.shell_on_fail"]), I found two key differences between Hyper-V and physical machine:

  • On physical machine, file of /dev/sd*//dev/nvme* and directory of /dev/disk don’t exist.
  • On physical machine, modprobe throws errors such as ERROR: could not insert 'hv_balloon'/'hv_netvsc'/'hv_storvsc'/'hv_utils'/'hv_vmbus': No such device`. But on Hyper-V, these modules loads successfully.

What should I do next? Thanks a lot.

This is almost certainly because nixos-generate-config detects which kernel modules to add to the boot.initrd.availableKernelModules based on the running system (i.e. the live ISO environment). It detected a number of kernel modules that make the system work in the VM but don’t help a physical system.

The inclusion of VM-specific modules is not a problem; the could not insert 'hv_ballon' messages are just harmless info and don’t matter. But you do need the necessary drivers for the physical storage, e.g. boot.initrd.availableKernelModules = [ "nvme" ];.

Finally, you can just enable the hardware.enableAllHardware = true; option in configuration.nix to try to make it so it can boot off of damn near anything, at the expense of making the initrd larger and consuming more space on the ESP.