Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 916861

Summary: sys-boot/grub-2.06-r9: grub-mkconfig generates wrong path for initramfs
Product: Gentoo Linux Reporter: Joerg Schaible <joerg.schaible>
Component: Current packagesAssignee: Mike Gilbert <floppym>
Status: RESOLVED INVALID    
Severity: normal CC: base-system
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Joerg Schaible 2023-11-04 17:24:23 UTC
On my new machine my kernel and all my initrd files are located in the boot partition  mounted at "/boot":
- initramfs-6.1.53-gentoo-r1-x86_64.img
- intel-uc.img
- vmlinuz-6.1.53-gentoo-r1-x86_64

Running "grub-mkconfig -o /boot/grub/grub.cfg" I get the following output:

============= %< ============
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.1.53-gentoo-r1-x86_64
Found initrd image: /boot/intel-uc.img /boot//boot/initramfs-6.1.53-gentoo-r1-x86_64.img
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
done
============= %< ============

And the created file will contain the following line to loard the initrd files after the kernel:

============= %< ============
initrd  /intel-uc.img //boot/initramfs-6.1.53-gentoo-r1-x86_64.img
============= %< ============

However, since the path for initramfs is wrong, the kernel panics. If I edit at boot time with the grub editor and remove the "//boot" part, the boot process succeeds.

Note: This worked on my old system for ages, since there was always a symlink "/boot -> .", but in the new system the boot partition is fat32, so no symlinks possible.

Reproducible: Always

Steps to Reproduce:
1. Generate a kernel with an initramfs (e.g. with genkernel)
2. Generate the grub.cfg

Actual Results:  
The path for the initramfs file in grub.cfg is wrong.

Expected Results:  
The path should not contain the mount point.

The problem is in the file /etc/grub.d/10_linux which does not use the proper variable to generate the path for the grub.cfg file:

$ diff -u tmp/mem/10_linux /etc/grub.d/10_linux 
--- tmp/mem/10_linux    2023-11-04 17:42:22.847679854 +0100
+++ /etc/grub.d/10_linux        2023-11-04 14:26:13.805463301 +0100
@@ -225,7 +225,7 @@
           "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
           "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do
     if test -e "${dirname}/${i}" ; then
-      initrd_real="${dirname}/${i}"
+      initrd_real="${rel_dirname}/${i}"
       # initrd_real="intel-ucode.cpio ${dirname}/${i}"
       break
     # else
Comment 1 Mike Gilbert gentoo-dev 2023-11-04 17:46:38 UTC
The file 10_linux file shipped with grub-2.06-r9 contains this:

>  initrd_real=
>  for i in "initrd.img-${version}" "initrd-${version}.img" \
>           "initrd-${alt_version}.img.old" "initrd-${version}.gz" \
>           "initrd-${alt_version}.gz.old" "initrd-${version}" \
>           "initramfs-${version}.img" "initramfs-${alt_version}.img.old" \
>           "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
>           "initrd-${alt_version}" "initramfs-${alt_version}.img" \
>           "initramfs-genkernel-${version}" \
>           "initramfs-genkernel-${alt_version}" \
>           "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
>           "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do
>    if test -e "${dirname}/${i}" ; then
>      initrd_real="${i}"
>      break
>    fi
>  done

${dirname} is not used when assigning initrd_real.

I think maybe you modified the file multiple times?
Comment 2 Joerg Schaible 2023-11-04 21:36:35 UTC
Strange. I'm not aware, that I touched this file before. And I had this also on another machine in the same way.

However, both machines are very old installations (nearly ~20 years), continuously updated (or moved to new hardware). My oldest backup (4 years) already has this modification and it seems, dispatch-conf keeps that change silently. At least, I can tell, that in the beginning I had no genkernel...

I'll remove the file, re-emerge grub and will report back.
Comment 3 Joerg Schaible 2023-11-05 23:29:47 UTC
As you've reported, the unmodified file of the current grub version looks as you've reported, so this must have been a modification on my side done a LOT of years ago...