nix-community / nixos-generators

Collection of image builders [maintainer=@Lassulus]
MIT License
1.84k stars 145 forks source link

`raw-efi` flashed onto usb drive does not boot on physical machine #171

Open karthanistyr opened 2 years ago

karthanistyr commented 2 years ago

Issue: booting a physical machine (Asus Zenbook UAK330UA) using a usb drive flashed with a freshly built nixos raw-efi image brings up the gray splash screen with logo, but does not progress further. All controls are unresponsive and the machine is locked. Hard reboot necessary.

reproducing with the following flake:

{
  description = "test image";

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-22.05";
    nixos-generators = {
      url = "github:nix-community/nixos-generators/1.6.0";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, nixos-generators, ... }: {
    packages.x86_64-linux = {
      kiosk =
        let
          pkgs = nixpkgs.legacyPackages.x86_64-linux;
        in
        nixos-generators.nixosGenerate {
          inherit pkgs;
          format = "raw-efi";
        };
      default = self.packages.x86_64-linux.kiosk;
    };
  };
}

Then nix build. The resulting result/nixos.img is flashed onto a usb drive via: (change sdX to appropriate device)

% dd if=result/nixos.img of=/dev/sdX bs=16M oflag=sync status=progress

The partition layout looks fine, with a 230 MB ESP partition, and roughly 2 GB primary partition for nixos.

Capture_2022-07-26_16-17-16 686547252

vivlim commented 1 year ago

I tried this today and found two issues:

  1. raw-efi has a fstab entry for mounting an ESP at /dev/vda1, which doesn't exist on hardware. I opened a PR to fix this: #198
  2. The grub config for raw and raw-efi adds console=ttyS0 to the kernel command line, which redirects all console output to a (likely non-existent) serial console instead of your monitor. This can be worked around by adding boot.kernelParams = [ "console=tty0" ]; to your configuration; this will be added after console=ttyS0, overriding it.