Skip to content

Install-iso: waiting for /dev/root on boot then fails #432

@phodina

Description

@phodina

Hi
,
I encountered issue where I'm cross compiling for aarch64 to create a bootable USB drive.

However, on target (Lenovo x13s) when booting I endup failing mounting the rootfs.

With error waiting for /dev/root.

I tried also the iso where I have the same issue.

I wanted to use the raw-efi but there it fails due to memory when copying content to the image. Tried to increase memory without any change.

Also tried sdcard but that will not boot due to missing EFI.

Could you please help?

{
  description = "NixOS aarch64 bootable USB with EFI boot";
  
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixos-generators = {
      url = "github:nix-community/nixos-generators";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    x13s-nixos = {
      url = "github:BrainWart/x13s-nixos";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  
  outputs = { self, nixpkgs, nixos-generators, x13s-nixos, ... }@inputs:
    let
      system = "x86_64-linux";
      targetSystem = "aarch64-linux";
      pkgs = import nixpkgs {
        inherit system;
        config.allowUnfree = true;
        crossSystem = {
          config = targetSystem;
          # Reduce build size by disabling documentation
          documentation.enable = false;
          documentation.doc.enable = false;
          documentation.info.enable = false;
          documentation.man.enable = false;
        };
      };
      
      x13s-pkgs = x13s-nixos.legacyPackages.${targetSystem} or
                 (x13s-nixos.packages.${targetSystem} or
                 (import "${x13s-nixos}" { 
                   inherit system; 
                   crossSystem.config = targetSystem;
                 }));

      lib = nixpkgs.lib;
    in {
      packages.${system} = {
        bootable-usb = nixos-generators.nixosGenerate {
          inherit pkgs;
          format = "install-iso";
          
          modules = [
            ({ config, pkgs, lib, ... }: {
              nixpkgs.hostPlatform = targetSystem;
              nixpkgs.buildPlatform = system;
              
              # Enable cross-compilation
              nixpkgs.crossSystem = {
                config = targetSystem;
              };
              system.stateVersion = "25.05";
              
              # Configure ISO image
              isoImage = {
                makeEfiBootable = true;
                makeUsbBootable = true;
                volumeID = "NIXOS_ISO";
                isoName = "nixos-aarch64.iso";
              };
              
              # Disable X11 to save memory
              services.xserver = {
                enable = false;
                displayManager.gdm.enable = false;
              };

              # User setup
              services.openssh.enable = true;
              users.users.nixos = {
                isNormalUser = true;
                extraGroups = [ "wheel" ];
                initialPassword = "nixos";
              };
              
              # Boot configuration for aarch64 with EFI support
              boot = {
                # Disable grub and use systemd-boot instead
                loader.grub.enable = false;
                loader.generic-extlinux-compatible.enable = false;
                
                # Enable EFI boot with systemd-boot
                loader.systemd-boot.enable = true;
                loader.efi.canTouchEfiVariables = true;
                
                # Kernel packages
                kernelPackages = x13s-pkgs.linux_jhovold or
                               (x13s-pkgs.linuxPackages_jhovold or
                               (x13s-pkgs.linuxPackages-jhovold or pkgs.linuxPackages));
                
                # Make sure initrd has all needed modules
                initrd = {
                  availableKernelModules = [
                    # Filesystems
                    "ext4" "vfat"
                    
                    # Storage
                    "usbhid" "usb_storage" "uas" "sd_mod" "sr_mod"
                    "mmc_block" "sdhci" "sdhci_pci" "sdhci_acpi"
                    
                    # ARM/aarch64 specific
                    "virtio_pci" "virtio_blk" "virtio_scsi"
                    "ahci" "nvme" "xhci_pci" "xhci_hcd"
                  ];
                  
                  # Force inclusion of important firmware paths in the initrd
                  includeDefaultModules = true;
                  kernelModules = [ 
                    # Basic display drivers
                    "drm" "drm_kms_helper" "gpu_sched" 
                    # For arm64 platforms
                    "qcom_geni_serial" "arm_smmu" "qcom_scm"
                    # Commonly needed on Qualcomm devices (like X13s)
                    "msm" "pinctrl_msm"
                  ];

                  # Enable verbose output during boot
                  verbose = true;
                };
                
                # Kernel parameters
                kernelParams = [ 
                  "arm64.nopauth" 
                  "clk_ignore_unused" 
                  "pd_ignore_unused" 
                  
                  # Console settings
                  "console=tty0"
                  "console=ttyS0,115200"
                  "console=tty1"
                  "earlycon=ttyS0,115200"
                  
                  # Prevent console/screen blanking
                  "consoleblank=0"
                  "no_console_suspend"
                  "fbcon=nodefer"
                  
                  # Graphics settings
                  "nomodeset"
                ];
              };
              
              # Enhanced hardware and firmware support
              hardware = {
                enableRedistributableFirmware = true;
                enableAllFirmware = true;
                
                # Include all firmware packages
                firmware = with pkgs; [
                  linux-firmware
                  firmwareLinuxNonfree
                  wireless-regdb
                ];
              };

              # Explicitly enable required filesystems
              boot.supportedFilesystems = [ "vfat" "ext4" ];
              
              # Add nixpkgs channel
              nix.nixPath = [ "nixpkgs=${nixpkgs}" ];
              
              # Enable flakes
              nix.settings.experimental-features = [ "nix-command" "flakes" ];
              
              # Add useful tools for debugging and setup
              environment.systemPackages = with pkgs; [
                git
                vim
                wget
                htop
                parted
                gptfdisk
                e2fsprogs
                usbutils
                pciutils
              ];
            })
          ];
        };
        default = self.packages.${system}.bootable-usb;
      };
    };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions