# grub2-mkconfig doesn't detect initrd

## devilkin

Hello Folks,

Recently (re)installed Gentoo, built kernel with genkernel and custom configuration, and it deposited a nice bzimage + initrd:

```
# ls -l /boot

total 7129

drwxr-xr-x 4 root root    1024 Apr 18 17:40 grub2

-rw-r--r-- 1 root root 3402655 Apr 20 12:06 initramfs-genkernel-x86_64-3.2.12-gentoo

-rw-r--r-- 1 root root 2209264 Apr 20 12:00 kernel-genkernel-x86_64-3.2.12-gentoo

drwx------ 2 root root   12288 Apr 18 14:47 lost+found

-rw-r--r-- 1 root root 1641455 Apr 20 12:00 System.map-genkernel-x86_64-3.2.12-gentoo

```

Unfortunately, when I wanted to update my grub2 config with grub2-mkconfig, it didn't detect the initrd, and didn't include it in the config.

Grub version is  sys-boot/grub 2.00_beta3-r1.

example of grub2-mkconfig:

```
## BEGIN /etc/grub.d/10_linux ###

Found linux image: /boot/kernel-genkernel-x86_64-3.2.12-gentoo

menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-b4019261-0c0c-478b-a2c0-7cf16e08a6f2' {

        load_video

        insmod gzio

        insmod part_gpt

        insmod ext2

        set root='hd0,gpt2'

        if [ x$feature_platform_search_hint = xy ]; then

          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  c3dadd34-40dc-4129-8228-954121ab7b38

        else

          search --no-floppy --fs-uuid --set=root c3dadd34-40dc-4129-8228-954121ab7b38

        fi

        echo    'Loading Linux x86_64-3.2.12-gentoo ...'

        linux   /kernel-genkernel-x86_64-3.2.12-gentoo root=/dev/mapper/macbook-root ro dolvm rootfstype=ext4 

}

submenu 'Advanced options for Gentoo GNU/Linux' $menuentry_id_option 'gnulinux-advanced-b4019261-0c0c-478b-a2c0-7cf16e08a6f2' {

        menuentry 'Gentoo GNU/Linux, with Linux x86_64-3.2.12-gentoo' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-x86_64-3.2.12-gentoo-advanced-b4019261-0c0c-478b-a2c0-7cf16e08a6f2' {

                load_video

                insmod gzio

                insmod part_gpt

                insmod ext2

                set root='hd0,gpt2'

                if [ x$feature_platform_search_hint = xy ]; then

                  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  c3dadd34-40dc-4129-8228-954121ab7b38

                else

                  search --no-floppy --fs-uuid --set=root c3dadd34-40dc-4129-8228-954121ab7b38

                fi

                echo    'Loading Linux x86_64-3.2.12-gentoo ...'

                linux   /kernel-genkernel-x86_64-3.2.12-gentoo root=/dev/mapper/macbook-root ro dolvm rootfstype=ext4 

        }

        menuentry 'Gentoo GNU/Linux, with Linux x86_64-3.2.12-gentoo (recovery mode)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-x86_64-3.2.12-gentoo-recovery-b4019261-0c0c-478b-a2c0-7cf16e08a6f2' {

                load_video

                insmod gzio

                insmod part_gpt

                insmod ext2

                set root='hd0,gpt2'

                if [ x$feature_platform_search_hint = xy ]; then

                  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  c3dadd34-40dc-4129-8228-954121ab7b38

                else

                  search --no-floppy --fs-uuid --set=root c3dadd34-40dc-4129-8228-954121ab7b38

                fi

                echo    'Loading Linux x86_64-3.2.12-gentoo ...'

                linux   /kernel-genkernel-x86_64-3.2.12-gentoo root=/dev/mapper/macbook-root ro single dolvm rootfstype=ext4

        }

}

### END /etc/grub.d/10_linux ###

```

As you can see - no initrd. The code in /etc/grub/10_linux looks good for initrd detection, so I have no clue as to why it doesn't pick it up...

Anyone any idea?

----------

## Arkhelion

The code for initrd is buggy in 10-linux because the $version contains $arch, so it looks for "initramfs-genkernel-x86_64-x86_64-3.3.2-gentoo" for instance. You have to correct the $version variable affectation or use "initramfs-genkernel-$(version)" without $arch to make it work.

EDIT : BTW I reinstalled grub-1.99 because 2.00_betaX (tries them all) couldn't find my LVM volumes (boot-on-realpart - root on LVM here), didn't have time to dig it up, so I just downgraded.

----------

## devilkin

Thanks, that did the trick. I guess I'll either look for a bug report or file one  :Wink: 

----------

## jinn

For completeness the actual patterns searched for by grub2-mkconfig are the following:

```

for i in 

        '"initrd.img-${version}"' 

        '"initrd-${version}.img"'

        '"initrd-${version}.gz"'

        '"initrd-${version}"'

        '"initramfs-${version}.img"'

        '"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}"'

```

----------

