Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
add special entry in grub for latest kernel [solved]
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
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5910

PostPosted: Thu Oct 15, 2020 9:49 pm    Post subject: add special entry in grub for latest kernel [solved] Reply with quote

Greetings,

when running grub-mkconfig -o /boot/grub/grub.cfg after a new kernel inclusion, I get an entry based on /etc/default/grub.
I need to create another identical entry but with different set of GRUB_CMDLINE_LINUX_DEFAULT.

any idea how can I achieve that?

Thanks,

Dagg.
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein


Last edited by DaggyStyle on Fri Oct 16, 2020 10:27 pm; edited 1 time in total
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Thu Oct 15, 2020 11:05 pm    Post subject: Reply with quote

You can manually edit grub.cfg
Code:

#####ORIGINAL ENTRY
menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-99d6e8e5-00b7-4975-9fde-8ad8451703d5' {
        load_video
        if [ "x$grub_platform" = xefi ]; then
                set gfxpayload=keep
        fi
        insmod gzio
        insmod part_gpt
        insmod ext2
        set root='hd1,gpt3'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,gpt3' --hint-bios=hd1,gpt3 --hint-efi=hd1,gpt3 --hint-baremetal=ahci1,gpt3  bdcfcb7b-5a6f-4519-a124-43436abedd40
        else
          search --no-floppy --fs-uuid --set=root bdcfcb7b-5a6f-4519-a124-43436abedd40
        fi
        echo    'Loading Linux 5.8.5-gentoo ...'
        linux   /vmlinuz-5.8.5-gentoo root=/dev/mapper/gen-root ro root=/dev/mapper/gen-root rootfstype=ext4 net.ifnames=0 biosdevname=0 sysrq_always_enabled=1 panic=20 audit=0 selinux=0 nvidia-drm.modeset=1 miti>
        echo    'Loading initial ramdisk ...'
        initrd  /intel-uc.img /initramfs-5.8.5-gentoo.img
}



######NEW UPDATED ENTRY
menuentry 'Gentoo GNU/Linux WITH DIFFERENT CMDLINE ARGS' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-99d6e8e5-00b7-4975-9fde-8ad8451703d5' {
        load_video
        if [ "x$grub_platform" = xefi ]; then
                set gfxpayload=keep
        fi
        insmod gzio
        insmod part_gpt
        insmod ext2
        set root='hd1,gpt3'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,gpt3' --hint-bios=hd1,gpt3 --hint-efi=hd1,gpt3 --hint-baremetal=ahci1,gpt3  bdcfcb7b-5a6f-4519-a124-43436abedd40
        else
          search --no-floppy --fs-uuid --set=root bdcfcb7b-5a6f-4519-a124-43436abedd40
        fi
        echo    'Loading Linux 5.8.5-gentoo ...'
        linux   /vmlinuz-5.8.5-gentoo root=/dev/mapper/gen-root ro root=/dev/mapper/gen-root rootfstype=ext4 net.ifnames=0 biosdevname=0 sysrq_always_enabled=1 panic=20 audit=0 selinux=0 nvidia-drm.modeset=1 miti>
        echo    'Loading initial ramdisk ...'
        initrd  /intel-uc.img /initramfs-5.8.5-gentoo.img
}



Modifying the
" linux /vmlinuz"
line to reflect your needs.
:D
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


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

PostPosted: Thu Oct 15, 2020 11:53 pm    Post subject: Reply with quote

Why do you run grub-mkconfig at all? It creates ugly and unreadable grub.cfg files.

A small and static grub.cfg is sufficient. See: https://forums.gentoo.org/viewtopic-p-8122378.html#8122378

Below is my grub.cfg:
Code:
timeout=5
default=0
menu_color_normal=white/blue

menuentry 'Linux' {
   set root='hd0,msdos1'
   linux /vmlinuz root=/dev/nvme0n1p2 ro net.ifnames=0 init=/usr/lib/systemd/systemd
}

menuentry 'Linux Backup' {
   set root='hd0,msdos1'
   linux /vmlinuz-Backup root=/dev/nvme0n1p2 ro net.ifnames=0 init=/usr/lib/systemd/systemd
}
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5910

PostPosted: Fri Oct 16, 2020 7:20 am    Post subject: Reply with quote

alamahant wrote:
You can manually edit grub.cfg
Code:

#####ORIGINAL ENTRY
menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-99d6e8e5-00b7-4975-9fde-8ad8451703d5' {
        load_video
        if [ "x$grub_platform" = xefi ]; then
                set gfxpayload=keep
        fi
        insmod gzio
        insmod part_gpt
        insmod ext2
        set root='hd1,gpt3'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,gpt3' --hint-bios=hd1,gpt3 --hint-efi=hd1,gpt3 --hint-baremetal=ahci1,gpt3  bdcfcb7b-5a6f-4519-a124-43436abedd40
        else
          search --no-floppy --fs-uuid --set=root bdcfcb7b-5a6f-4519-a124-43436abedd40
        fi
        echo    'Loading Linux 5.8.5-gentoo ...'
        linux   /vmlinuz-5.8.5-gentoo root=/dev/mapper/gen-root ro root=/dev/mapper/gen-root rootfstype=ext4 net.ifnames=0 biosdevname=0 sysrq_always_enabled=1 panic=20 audit=0 selinux=0 nvidia-drm.modeset=1 miti>
        echo    'Loading initial ramdisk ...'
        initrd  /intel-uc.img /initramfs-5.8.5-gentoo.img
}



######NEW UPDATED ENTRY
menuentry 'Gentoo GNU/Linux WITH DIFFERENT CMDLINE ARGS' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-99d6e8e5-00b7-4975-9fde-8ad8451703d5' {
        load_video
        if [ "x$grub_platform" = xefi ]; then
                set gfxpayload=keep
        fi
        insmod gzio
        insmod part_gpt
        insmod ext2
        set root='hd1,gpt3'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,gpt3' --hint-bios=hd1,gpt3 --hint-efi=hd1,gpt3 --hint-baremetal=ahci1,gpt3  bdcfcb7b-5a6f-4519-a124-43436abedd40
        else
          search --no-floppy --fs-uuid --set=root bdcfcb7b-5a6f-4519-a124-43436abedd40
        fi
        echo    'Loading Linux 5.8.5-gentoo ...'
        linux   /vmlinuz-5.8.5-gentoo root=/dev/mapper/gen-root ro root=/dev/mapper/gen-root rootfstype=ext4 net.ifnames=0 biosdevname=0 sysrq_always_enabled=1 panic=20 audit=0 selinux=0 nvidia-drm.modeset=1 miti>
        echo    'Loading initial ramdisk ...'
        initrd  /intel-uc.img /initramfs-5.8.5-gentoo.img
}



Modifying the
" linux /vmlinuz"
line to reflect your needs.
:D


I'd rather have grub-mkconfig create it as it can handle older versions, thanks for the suggestion thought
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5910

PostPosted: Fri Oct 16, 2020 7:21 am    Post subject: Reply with quote

mike155 wrote:
Why do you run grub-mkconfig at all? It creates ugly and unreadable grub.cfg files.

A small and static grub.cfg is sufficient. See: https://forums.gentoo.org/viewtopic-p-8122378.html#8122378

Below is my grub.cfg:
Code:
timeout=5
default=0
menu_color_normal=white/blue

menuentry 'Linux' {
   set root='hd0,msdos1'
   linux /vmlinuz root=/dev/nvme0n1p2 ro net.ifnames=0 init=/usr/lib/systemd/systemd
}

menuentry 'Linux Backup' {
   set root='hd0,msdos1'
   linux /vmlinuz-Backup root=/dev/nvme0n1p2 ro net.ifnames=0 init=/usr/lib/systemd/systemd
}


because I want to keep older versions and don't have to maintain the file myself.

I think I have a possible solution, will update.
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
Back to top
View user's profile Send private message
halcon
l33t
l33t


Joined: 15 Dec 2019
Posts: 629

PostPosted: Fri Oct 16, 2020 9:03 am    Post subject: Reply with quote

mike155 wrote:
Why do you run grub-mkconfig at all? It creates ugly and unreadable grub.cfg files.

A small and static grub.cfg is sufficient. See: https://forums.gentoo.org/viewtopic-p-8122378.html#8122378

Thank you! Good to know.
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2014

PostPosted: Fri Oct 16, 2020 9:15 am    Post subject: Reply with quote

DaggyStyle wrote:
... because I want to keep older versions and don't have to maintain the file myself. ...

You might like to try my static grub.cfg file that works for current and old versions (assuming you use the /boot/vmlinuz-5.9.0-foo naming conventions and the symbolic or hard links for /boot/vmlinuz, and optionally ditto for initramfs...img files). Once configured, never needs updating, and uses the grub shell script to generate a submenu of all the old kernels.
_________________
Greybeard
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5910

PostPosted: Fri Oct 16, 2020 9:34 am    Post subject: Reply with quote

Goverp wrote:
DaggyStyle wrote:
... because I want to keep older versions and don't have to maintain the file myself. ...

You might like to try my static grub.cfg file that works for current and old versions (assuming you use the /boot/vmlinuz-5.9.0-foo naming conventions and the symbolic or hard links for /boot/vmlinuz, and optionally ditto for initramfs...img files). Once configured, never needs updating, and uses the grub shell script to generate a submenu of all the old kernels.


thanks for the suggestion, however I cannot use it as afaik, links are not possible in vfat.
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Fri Oct 16, 2020 9:51 am    Post subject: Reply with quote

What you CAN do is add your modified entry in
Code:

/etc/grub.d/41_custom

This way grub will auto add it every time you run grub update.
:D
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


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

PostPosted: Fri Oct 16, 2020 11:35 am    Post subject: Reply with quote

'make install' of the vanilla kernel installs the kernel to /boot/vmlinuz. And the old kernel is copied to /boot/vmlinuz.old.

A static grub.cfg is perfectly fine if one uses the default Linux kernel install method. There's no need to change anything in grub.cfg.

But there are tools like 'debiantools', which install hooks in /etc/kernel/install.d/. These hooks modify 'make install' so that it installs the kernel to /boot/vmlinuz-X.Y.Z. And then it's necessary to run grub-mkconfig after 'make install', because the name of kernel image changes with every new version of the kernel.

But if you think about it - it's probably much better to use the default install method (install the kernel to /boot/vmlinuz) than to have the version in the images' names and to run 'grub-mkconfig' every time a new kernel is installed.
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5910

PostPosted: Fri Oct 16, 2020 12:13 pm    Post subject: Reply with quote

alamahant wrote:
What you CAN do is add your modified entry in
Code:

/etc/grub.d/41_custom

This way grub will auto add it every time you run grub update.
:D

the solution I'm working on uses 40_custom
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5910

PostPosted: Fri Oct 16, 2020 12:40 pm    Post subject: Reply with quote

mike155 wrote:
'make install' of the vanilla kernel installs the kernel to /boot/vmlinuz. And the old kernel is copied to /boot/vmlinuz.old.

A static grub.cfg is perfectly fine if one uses the default Linux kernel install method. There's no need to change anything in grub.cfg.

But there are tools like 'debiantools', which install hooks in /etc/kernel/install.d/. These hooks modify 'make install' so that it installs the kernel to /boot/vmlinuz-X.Y.Z. And then it's necessary to run grub-mkconfig after 'make install', because the name of kernel image changes with every new version of the kernel.

But if you think about it - it's probably much better to use the default install method (install the kernel to /boot/vmlinuz) than to have the version in the images' names and to run 'grub-mkconfig' every time a new kernel is installed.


I'm not using make install, I got used to copy bzImage and rename it to something more meaningful which for example holds the kernel version.

looks like my script read, I just hope it works
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5910

PostPosted: Fri Oct 16, 2020 10:27 pm    Post subject: Reply with quote

wrote a script that grub-mkconfig to temp file, than takes the relevant entry and place it in 40_custom.
then it runs grub-mkconfig into the correct file, works like a charm.

thanks for the suggestions.
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
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