Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
my grub-mkconfig seems to be ignoring 10_linux file
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Amon2501
Tux's lil' helper
Tux's lil' helper


Joined: 12 Dec 2018
Posts: 131

PostPosted: Tue Feb 08, 2022 5:53 pm    Post subject: my grub-mkconfig seems to be ignoring 10_linux file Reply with quote

Hello. I have dualboot with windows 7, so i did my grub.cfg about 5 years ago and didn't updated it since then. Today i ran grub-mkconfig with output to test file and compared it with my actual config. Big surprise - NO LINUX. It only detects the windows partition. Here is my original working file (menu entries part)

Code:
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-dd84ddf8-0856-4dd6-be78-0fe0d9dc2fd1' {
        load_video
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos2'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2  dd84ddf8-0856-4dd6-be78-0fe0d9dc2fd1
        else
          search --no-floppy --fs-uuid --set=root dd84ddf8-0856-4dd6-be78-0fe0d9dc2fd1
        fi
        echo    'Загружается Linux'
        linux   /boot/vmlinuz root=/dev/sda2 ro 
}
submenu 'Дополнительные параметры для Gentoo GNU/Linux' $menuentry_id_option 'gnulinux-advanced-dd84ddf8-0856-4dd6-be78-0fe0d9dc2fd1' {
        menuentry 'Gentoo GNU/Linux, предыдущее ядро' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.39-gentoo-advanced-dd84ddf8-0856-4dd6-be78-0fe0d9dc2fd1' {
                load_video
                insmod gzio
                insmod part_msdos
                insmod ext2
                set root='hd0,msdos2'
                if [ x$feature_platform_search_hint = xy ]; then
                  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2  dd84ddf8-0856-4dd6-be78-0fe0d9dc2fd1
                else
                  search --no-floppy --fs-uuid --set=root dd84ddf8-0856-4dd6-be78-0fe0d9dc2fd1
                fi
                echo    'Загружается Linux old'
                linux   /boot/vmlinuz.old root=/dev/sda2 ro 
        }
}

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

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows 7 (loader) (на /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-545DAB33A275F517' {
        insmod part_msdos
        insmod ntfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  545DAB33A275F517
        else
          search --no-floppy --fs-uuid --set=root 545DAB33A275F517
        fi
        parttool ${root} hidden-
        chainloader +1
}


And here is what i ve got in that newer test cfg file

Code:
### END /etc/grub.d/00_header ###

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

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

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows 7 (на /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-545DAB33A275F517' {
        insmod part_msdos
        insmod ntfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  545DAB33A275F517
        else
          search --no-floppy --fs-uuid --set=root 545DAB33A275F517
        fi
        parttool ${root} hidden-
        chainloader +1
}
### END /etc/grub.d/30_os-prober ###


See? No linux entries at all! But why? How can i make it to detect Linux too?
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Tue Feb 08, 2022 6:21 pm    Post subject: Reply with quote

You have
Code:

linux   /boot/vmlinuz root=/dev/sda2 ro

Plz rename your kernel to vmlinuz-<version> and your initrd if any to initramfs-<version>.img
In <version> you can use any string you like.
But preferably plz use the actual(numeric) version of the kernel which you can see by
Code:

ls /lib/modules

then update grub.
For some more detail plz see
Code:

globs="$GRUB_LINUX_KERNEL_GLOBS"
167 [ -z "$globs" ] && case "x$machine" in
168     xi?86 | xx86_64)
169   globs="/boot/vmlinuz-* /vmlinuz-* /boot/kernel-*"
170   ;;
171     *)
172   globs="/boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-*"
173   ;;
174 esac


and
Code:

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}"; do
    if test -e "${dirname}/${i}" ; then
      initrd_real="${i}"
      break
    fi
  done


These are the naming formats for kernel and initrd that grub will recognize as legitimate
according to
/etc/grub.d/10_linux
_________________
:)
Back to top
View user's profile Send private message
Amon2501
Tux's lil' helper
Tux's lil' helper


Joined: 12 Dec 2018
Posts: 131

PostPosted: Tue Feb 08, 2022 7:17 pm    Post subject: Reply with quote

alamahant wrote:
You have
Code:

linux   /boot/vmlinuz root=/dev/sda2 ro

Plz rename your kernel to vmlinuz-<version> and your initrd if any to initramfs-<version>.img
In <version> you can use any string you like.
But preferably plz use the actual(numeric) version of the kernel which you can see by


I didnt changed the name of a kernel file myself. That name was generated by "make bzImage && make install" commands every time i bult it from the gentoo-sources package. Also im okay with just vmlinuz and vmlinux.old since i dont want to keep more than one recent and one "backup" kernels and only in case something goes wrong.
Also i dont have initrd because its just the root ext4 partition not RAID nor SSD.
Quote:

Code:

ls /lib/modules

then update grub.
For some more detail plz see
Code:

globs="$GRUB_LINUX_KERNEL_GLOBS"
167 [ -z "$globs" ] && case "x$machine" in
168     xi?86 | xx86_64)
169   globs="/boot/vmlinuz-* /vmlinuz-* /boot/kernel-*"
170   ;;
171     *)
172   globs="/boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-*"
173   ;;
174 esac


and
Code:

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}"; do
    if test -e "${dirname}/${i}" ; then
      initrd_real="${i}"
      break
    fi
  done


These are the naming formats for kernel and initrd that grub will recognize as legitimate
according to
/etc/grub.d/10_linux[/quote]

But that working cfg file also was generated someday by grub-mkconfig, not written by me. Was anything changed in it?
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Tue Feb 08, 2022 7:23 pm    Post subject: Reply with quote

Try renaming it plz and check if grub creates an entry..
I dont know if something changed.Probably-- since your grub.cfg was super old
Try renaming it to vmlinuz-gentoo or anything at least.
If you dont i think grub will ignore it.
Or you can modify the etc/grub.d/10_linux file.
or MUCH BETTER use 40_custom file
to create a static custom entry.
by appending
Code:

menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-dd84ddf8-0856-4dd6-be78-0fe0d9dc2fd1' {
        load_video
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos2'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2  dd84ddf8-0856-4dd6-be78-0fe0d9dc2fd1
        else
          search --no-floppy --fs-uuid --set=root dd84ddf8-0856-4dd6-be78-0fe0d9dc2fd1
        fi
        echo    'Загружается Linux'
        linux   /boot/vmlinuz root=/dev/sda2 ro
}

to it.
:)
_________________
:)
Back to top
View user's profile Send private message
Amon2501
Tux's lil' helper
Tux's lil' helper


Joined: 12 Dec 2018
Posts: 131

PostPosted: Tue Feb 08, 2022 8:00 pm    Post subject: Reply with quote

Thanks, that entry in 40_custom worked. The bad thing that it puts Gentoo entry after the windows now. which means windows will be loaded by default as the first one in list, but i think i can just copy and paste it manually back.
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2014

PostPosted: Tue Feb 08, 2022 8:11 pm    Post subject: Reply with quote

Amon2501 wrote:
Thanks, that entry in 40_custom worked. The bad thing that it puts Gentoo entry after the windows now. which means windows will be loaded by default as the first one in list, but i think i can just copy and paste it manually back.

And while you are editing it, you could also change the name to use "vmlinuz" without any version number, and ditto for the file, then it will find whatever "make install" creates.
You can also duplicate the entire entry but for "vmlinuz.old",, because I think you're find "make install" has moved the previous kernel to that name.

IMHO grub-mkconfig is a heap of crode.
_________________
Greybeard
Back to top
View user's profile Send private message
Amon2501
Tux's lil' helper
Tux's lil' helper


Joined: 12 Dec 2018
Posts: 131

PostPosted: Tue Feb 08, 2022 8:11 pm    Post subject: Reply with quote

Amon2501 wrote:
Thanks, that entry in 40_custom worked. The bad thing that it puts Gentoo entry after the windows now. which means windows will be loaded by default as the first one in list, but i think i can just copy and paste it manually back.


Also yes it started to recognise kernel afteri copied vmlinuz to vmlinuz-blahblah in /boot. The question now is Why "make install" produces only vmlinuz file instead of vmlinuz-something. As far as i could remember it was always named that way and never vmlinuz-<version>
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Tue Feb 08, 2022 8:12 pm    Post subject: Reply with quote

Or use
Code:

GRUB_DEFAULT=1 #or 2

in /etc/default/grub
_________________
:)
Back to top
View user's profile Send private message
Amon2501
Tux's lil' helper
Tux's lil' helper


Joined: 12 Dec 2018
Posts: 131

PostPosted: Tue Feb 08, 2022 8:19 pm    Post subject: Reply with quote

alamahant wrote:
Or use
Code:

GRUB_DEFAULT=1

in /etc/default/grub


That`s exactly why i found that strange behaviour and started that topic. I wanted to play a Windows game, so change the default boot to Windows for a while. Thanks goodness i didnt just "grub-mkconfig -o /boot/grub/grub.cfg" without checking it first.

PS BTW will GRUB_DEFAULT=saved work as it does in Fedora for example.
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Tue Feb 08, 2022 9:05 pm    Post subject: Reply with quote

I don't use grub-mkconfig at all. I have a short and handmade grub.cfg:
Code:
timeout=5
default=0
menu_color_normal=white/blue

menuentry 'Linux' {
   set root='hd0,msdos1'
   linux /vmlinuz root=/dev/nvme0n1p2 ro init=/usr/lib/systemd/systemd acpi_enforce_resources=lax
}
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2014

PostPosted: Wed Feb 09, 2022 9:23 am    Post subject: Reply with quote

Amon2501 wrote:
...
Also yes it started to recognise kernel afteri copied vmlinuz to vmlinuz-blahblah in /boot. The question now is Why "make install" produces only vmlinuz file instead of vmlinuz-something. As far as i could remember it was always named that way and never vmlinuz-<version>


"make install" ends up running /sbin/installkernel, which copies vmlinuz, .config and System.map to /boot. On my system, I get vmlinz-5.16.7-gentoo and so forth, with symlinks "vmlinuz" and "vmlinuz.old". If your /boot is on a vfat or suchlike filesystem (e.g. in the EFI partition) that doesn't support symlinks, perhaps the symlink process is fouling things up.
Alternatively, perhaps /sbin/installkernel isn't the Gentoo default which claims to be copyright 2009 from Debian. Mine seems to come from sys-kernel/installkernel-gentoo, but there's a different version in sys-kernel/installkernel-systemd-boot, and presumably another (broken) one in sys-apps/debianutils, according to the Portage file list.
_________________
Greybeard
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 2965
Location: Edge of marsh USA

PostPosted: Fri Feb 11, 2022 5:45 am    Post subject: Reply with quote

Goverp -- I knew there was an underlying reason why I don't run "make install" and instead hand jam my kernel files after building, i.e.:
Code:
$  ls -1 /boot/*5.10.93*
/boot/config-5.10.93-gentoo
/boot/kernel-5.10.93-gentoo
/boot/System.map-5.10.93-gentoo

I copy and paste the version from number the last line of the "make" standard output to avoid typos, and then update grub.cfg. I also make a symlink vmlinuz pointing to the new kernel in case I would need to boot with grub from a commandline. I personally prefer the name kernel to vmlinuz just because it's plain English and that's my native language. I do the whole kernel compile of gentoo-sources manually because if I didn't, I'd forget how to do it. I got my (bad) habits from a now ancient version of the gentoo-handbook.

I do miss the old grub because editing gbub.conf used to be muscle memory and I don't seem to be getting the same easy hang of editing /boot/grub/custom.cfg, but I do it or I wouldn't learn new things.
_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2014

PostPosted: Fri Feb 11, 2022 9:26 am    Post subject: Reply with quote

You might like my "universal" grub.cfg that has a base menu for booting from vmlinuz, vmlinuz.new and vmlinuz.old symlinks, and a submenu that lists all vmlinuz-n.nn.nn kernels sorted by version. I don't recall if it handles initramfs/initrd.
_________________
Greybeard
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Fri Feb 11, 2022 5:16 pm    Post subject: Reply with quote

Goverp wrote:
Amon2501 wrote:
...
Also yes it started to recognise kernel afteri copied vmlinuz to vmlinuz-blahblah in /boot. The question now is Why "make install" produces only vmlinuz file instead of vmlinuz-something. As far as i could remember it was always named that way and never vmlinuz-<version>


"make install" ends up running /sbin/installkernel, which copies vmlinuz, .config and System.map to /boot. On my system, I get vmlinz-5.16.7-gentoo and so forth, with symlinks "vmlinuz" and "vmlinuz.old". If your /boot is on a vfat or suchlike filesystem (e.g. in the EFI partition) that doesn't support symlinks, perhaps the symlink process is fouling things up.
Alternatively, perhaps /sbin/installkernel isn't the Gentoo default which claims to be copyright 2009 from Debian. Mine seems to come from sys-kernel/installkernel-gentoo, but there's a different version in sys-kernel/installkernel-systemd-boot, and presumably another (broken) one in sys-apps/debianutils, according to the Portage file list.
You can also make your own.

I recently discovered the INSTALLKERNEL variable:
https://www.kernel.org/doc/html/latest/kbuild/kbuild.html:
INSTALLKERNEL

Install script called when using “make install”. The default name is “installkernel”.

The script will be called with the following arguments:

        $1 - kernel version

        $2 - kernel image file

        $3 - kernel map file

        $4 - default install path (use root directory if blank)

The implementation of “make install” is architecture specific and it may differ from the above.

INSTALLKERNEL is provided to enable the possibility to specify a custom installer when cross compiling a kernel.

_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum