Skip to content

initrd build fails: ukl-base image does not install perf, but buildinitrd.sh lists it as required, causing an empty initrd and "Unable to mount root fs" panic #38

Description

@borkluce

Environment

  • UKL commit f66efb6c (Linux 6.3.0)
  • Default build path (initrd/create-initrd.sh, which builds inside the ukl-base Docker image)

Summary

The initrd build aborts and produces a near-empty (~25 KB) image whenever a binary listed in buildinitrd.sh is not present in the build container. Concretely, this happens with perf: the ukl-base image does not install it, but buildinitrd.sh treats it as required. The build appears to finish, but the kernel then panics at boot with Unable to mount root fs, with nothing linking the panic back to the missing binary.

Root cause (with references)

The initrd is built inside the ukl-base container (initrd/create-initrd.shdocker exec ... ./buildinitrd.sh). That image is Fedora 36 and installs its tools here (initrd/ukl-base/Dockerfile):

RUN dnf -y install sed elfutils-libelf-devel bc hostname perl dropbear \
        msr-tools wget dnf-plugins-core bzip2 curl xz cpio shadow-utils procps-ng iproute \
        pciutils net-tools openssh-server less ethtool

perf is not in this list. However, buildinitrd.sh requires it:

21  cp ./perf /usr/sbin/
33  sbinfiles="halt dropbear ip rdmsr wrmsr lspci perf ethtool"

Line 21 assumes a ./perf exists in the repo (it does not), and line 33 lists perf among the required sbinfiles. When copy() cannot find perf, it hits its failure branch:

15  echo "Missing required file: $1 for directory $2"
16  rm -rf $WDIR
17  exit 1

So the build deletes its working directory and exits with an incomplete initrd. The echo is easily missed in a verbose/parallel build, and rm -rf $WDIR removes any evidence, so the only symptom the user actually sees is an unexplained kernel panic much later.

Steps to reproduce

  1. Build the initrd via the standard path (create-initrd.sh) using the provided ukl-base image.
  2. Observe a ~25 KB initrd.
  3. Boot the kernel → Unable to mount root fs

Workaround

Removing perf from sbinfiles (line 33) produces a correctly populated initrd (~8 MB) and the kernel boots normally. perf was not required for my workload.

Suggested fix (any of):

  • Add perf to the ukl-base Dockerfile so the required set is actually present; or
  • Mark non-essential tools like perf as optional in buildinitrd.sh (warn and skip instead of aborting); and
  • Regardless, make the failure non-destructive and explicit: don't rm -rf $WDIR before the user can inspect it, and abort with an unmissable message naming the missing binary. The current silent-ish failure followed by a much later Unable to mount root fs is very hard to diagnose.

Offer

I hit this while integrating an application into UKL and traced it to the missing perf. I'd be glad to open a PR — either adding perf to the image, or making the missing-binary handling optional and non-destructive — if that's welcome.

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