NixOS / NixOS/nixpkgs

nixos-rebuild-ng: failure to copy the boot kernel image in the boot partition is not detected

Open
#500,035 18 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0.kind: bug
Dominant language
Nix
Stars
26.2k
Forks
20.1k
PR merge metrics
PR metrics pending

Description

Nixpkgs version
  • Stable (25.11)
Describe the bug

I updated my nixos-25.11 system using sudo nixos-rebuild boot as usual, and the program ended without signaling any problem (at least, not in a manner visible to the user). However, trying to reboot the new generation resulted in the error “…-linux-6.12.75-bzImage.efi: unsupported”. The /boot partition has plenty of free space.

$ df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p1  911M  109M  802M  12% /boot

The problem turned out to be that copying the kernel image in the /boot partition went wrong for an unknown reason (note kernel 6.12.75):

$ cd /boot/EFI/nixos; ll
total 66546
-rwxr-xr-x 1 root root 27825400 Mar  2 14:10 0vz4i6ykbxky5nsr4qpq6ar16w6y3rvx-initrd-linux-6.12.74-initrd.efi
-rwxr-xr-x 1 root root 12493312 Mar  2 14:10 asbw2z87v1m06408vpkwwam0vvwwdr5z-linux-6.12.74-bzImage.efi
-rwxr-xr-x 1 root root        0 Mar  9 10:49 qxsp35yd75xjvxiyyqvj0lpxsx2q58gl-linux-6.12.75-bzImage.efi
-rwxr-xr-x 1 root root 27822822 Mar  9 10:49 sd4034ylmvprc0102nwy865i91ml00qj-initrd-linux-6.12.75-initrd.efi

Re-running sudo nixos-rebuild boot didn’t rebuild anything and returned success. In spite of this, the 0 kB size kernel in the boot partition remained the same. To fix the problem I had to manually delete the 0 kB file and rerun nixos-rebuild.

nixos-rebuild should do more checks to verify that the generated kernel is installed correctly. A simple check that the size of the kernel copied in the boot partition matches the one on the store would caught these kind of problems.

This is important because, if old generations are deleted in an excess of confidence, the system becomes unbootable.

Steps to reproduce

Non reproducible.

Expected behaviour

nixos-rebuild should verify that the installed boot image is installed correctly. For example, by checking its size against the image in the store. If the checks fail, the error should be highlighted to the user.

Screenshots

No response

Relevant log output

Additional context

No response

System metadata
 - system: `"x86_64-linux"`
 - host os: `Linux 6.12.75, NixOS, 25.11 (Xantusia), 25.11.7198.71caefce12ba`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.31.2`
 - channels(beffa): `""`
 - channels(root): `"nixos-25.11"`
 - nixpkgs: `/nix/store/z9g260zjw29c18xgn57q4yark9is9qfg-nixos-25.11/nixos`
Notify maintainers

@thiagokokada


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs
Is this issue important to you?

Add a 👍 reaction to issues you find important.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the nixos-rebuild boot entry point and the path that copies the generated kernel into /boot/EFI/nixos. Compare the installed boot image with the corresponding image in the Nix store, and check how rerunning the command handles an existing zero-byte file. Done means copy failures or size mismatches are detected and clearly reported to the user.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.