Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 943214 - sys-kernel/genkernel-4.1.2-r3: fails to build only the initramfs
Summary: sys-kernel/genkernel-4.1.2-r3: fails to build only the initramfs
Status: UNCONFIRMED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-11 03:42 UTC by Dyweni
Modified: 2024-11-11 08:28 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dyweni 2024-11-11 03:42:21 UTC
I use genkernel to only build the initramfs image.

I have a script that wraps around genkernel to create the initramfs structure with binaries and libraries and a couple specific kernel modules.

Before I run my script, I've already installed my kernel modules into '/lib/modules/${KV}'.

When that's all done, I call genkernel like this:

genkernel \
  --no-mountboot \
  --kernel-config=/boot/config \
  --linuxrc=/boot/install.custom.linuxrc \
  --initramfs-overlay=$ol \
  --no-install \
  --lvm \
  --loglevel=2 \
  initramfs

It outputs a file here: /var/tmp/genkernel/initramfs-*

My script then moves that file into position under /boot.

This works fine on sys-kernel/genkernel-4.0.10.
It is broken on sys-kernel/genkernel-4.1.2-r3.

The error output I get with this version is:
ERROR: '/var/tmp/genkernel/gk_GcnixHcg/mod_prefix/lib/modules/5.4.80-gentoo-r1-20241110-194244' does not exist! Did you forget to compile kernel before building initramfs? If you know what you are doing please set '--no-ramdisk-modules'.


I think this commit is responsible: febeae936c626eb4c0a44654cda2a6351671098b

It defines 'KERNEL_MODULES_PREFIX="${TEMP}/mod_prefix"', where KERNEL_MODULES_PREFIX was previously unset.

Then in 'gen_initramfs.sh' / append_modules(), starting at line 1678:

---------
local modules_dstdir="${TDIR}/lib/modules/${KV}"
local modules_srcdir="/lib/modules/${KV}"

print_info 2 "$(get_indent 2)modules: >> Copying modules to initramfs ..."

if [ -n "${KERNEL_MODULES_PREFIX}" ]
then
  modules_srcdir="${KERNEL_MODULES_PREFIX%/}${modules_srcdir}"
fi

if [ ! -d "${modules_srcdir}" ]
then
  error_message="'${modules_srcdir}' does not exist! Did you forget"
  error_message+=" to compile kernel before building initramfs?"
  error_message+=" If you know what you are doing please set '--no-ramdisk-modules'."
  gen_die "${error_message}"
fi
---------

So the correct modules_srcdir gets changed to something under '/var/tmp/genkernel' and then fails because it doesn't exist.

The same pieces of code exist at version 4.3.16 (0bccb338abf8f986f94b2bd5c2df5ba4c566606d).



Reproducible: Always

Steps to Reproduce:
1. Build an install the kernel using make && make modules_install && make install
2. Run genkernel like this:

genkernel \
  --no-mountboot \
  --kernel-config=/boot/config \
  --linuxrc=/boot/install.custom.linuxrc \
  --initramfs-overlay=$ol \
  --no-install \
  --lvm \
  --loglevel=2 \
  initramfs

(You may not even need --linuxrc and --initramfs-overlay and --lvm options).
Actual Results:  
The error is produced:

ERROR: '/var/tmp/genkernel/gk_GcnixHcg/mod_prefix/lib/modules/5.4.80-gentoo-r1-20241110-194244' does not exist! Did you forget to compile kernel before building initramfs? If you know what you are doing please set '--no-ramdisk-modules'.

Expected Results:  
The initramfs image is created under /var/tmp/genkernel and ready to be manually moved.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-11 08:28:54 UTC
commit febeae936c626eb4c0a44654cda2a6351671098b
Author: Thomas Deutschmann <whissi@gentoo.org>
Date:   Mon Aug 3 00:01:21 2020 +0200

    gen_determineargs.sh: determine_real_args(): Set KERNEL_MODULES_PREFIX to temporary location when --no-install is set

    This will ensure that we won't install anything on user's system when
    --no-install was set.

    While here, make use of expand_file() for --kernel-modules-prefix.

    Bug: https://bugs.gentoo.org/505810
    Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>