initrd extra-utils build fails: patchelf "missing ELF header" on lvm/dmsetup
Nobody has claimed this yet.
- 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
- Build any NixOS configuration for aarch64-linux that uses the traditional (non-systemd) initrd
- The build fails during the
extra-utils.drvderivation
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:
- Check if files are ELF before running patchelf (e.g., check magic bytes)
- Make LVM inclusion conditional on actual LVM usage
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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