NixOS / NixOS/nixpkgs

initrd extra-utils build fails: patchelf "missing ELF header" on lvm/dmsetup

Open
#475,910 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

2.status: stale
Dominant language
Nix
Stars
26.2k
Forks
20.1k
PR merge metrics
PR metrics pending

Description

Description

Building NixOS for aarch64-linux fails during initrd extra-utils creation because lvm and dmsetup from pkgs.lvm2 are shell script wrappers instead of ELF binaries. The stage-1 builder runs patchelf on all binaries in extra-utils, which fails on these scripts.

Steps to reproduce

  1. Build any NixOS configuration for aarch64-linux that uses the traditional (non-systemd) initrd
  2. The build fails during the extra-utils.drv derivation

Error message

building '/nix/store/hpm8jllx9094js2y63m5nxcxzsg6pnhg-extra-utils.drv'...
patching /nix/store/plh2x621r67s8g4ma1ql0jss6k1jvmpd-extra-utils/bin/lvm...
patchelf: missing ELF header
patching /nix/store/plh2x621r67s8g4ma1ql0jss6k1jvmpd-extra-utils/bin/dmsetup...
patchelf: missing ELF header
patching /nix/store/plh2x621r67s8g4ma1ql0jss6k1jvmpd-extra-utils/lib/libpam.so.0...
patchelf: missing ELF header

Affected versions

  • Broken: cad22e7d996aea55ecab064e84834289143e44a0 (nixos-unstable ~2025-12-30)
  • Working: 2fbfb1d73d239d2402a8fe03963e37aab15abe8b

Root cause

In nixos/modules/system/boot/stage-1.nix, LVM tools are copied unconditionally:

copy_bin_and_libs ${getBin pkgs.lvm2}/bin/dmsetup
copy_bin_and_libs ${getBin pkgs.lvm2}/bin/lvm

The builder then runs patchelf on all files without checking if they're actually ELF binaries.

Suggested fix

Either:

  1. Check if files are ELF before running patchelf (e.g., check magic bytes)
  2. Make LVM inclusion conditional on actual LVM usage
  3. Fix lvm2 package to ensure lvm/dmsetup are actual ELF binaries, not script wrappers

Metadata

  • Architecture: aarch64-linux
  • NixOS version: 26.05 (unstable)

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 with nixos/modules/system/boot/stage-1.nix and reproduce the traditional initrd extra-utils build on aarch64-linux. Trace copy_bin_and_libs and the extra-utils patchelf step; done when lvm, dmsetup, and libpam no longer cause “missing ELF header” failures during the build.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.