Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
$ cat /etc/default/grub
#
# Configuration file for GRUB.
#
GRUB_DEFAULT=saved
#save last distro booted
GRUB_SAVEDEFAULT=true
#GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
#GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Void"
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=4 slub_debug=P page_poison=1"
# Uncomment to use basic console
#GRUB_TERMINAL_INPUT="console"
# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console
#GRUB_BACKGROUND=/usr/share/void-artwork/splash.png
GRUB_BACKGROUND=/boot/grub/images/tuxkiller3.png
GRUB_GFXMODE=1920x1080x32,1600x900x32,1600x900x24,1600x900x16,auto
GRUB_GFXPAYLOAD="keep"
#GRUB_DISABLE_LINUX_UUID=true
#GRUB_DISABLE_RECOVERY=true
# Uncomment and set to the desired menu colors. Used by normal and wallpaper
# modes only. Entries specified as foreground/background.
GRUB_COLOR_NORMAL="light-blue/black"
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"
what you are looking for is the advance options in the menu when you boot up, saving last boot might help, I'll have to reboot to check that, also you might be able to use 40_custom and write a menu in there that will always point to your specific kernel that you want to boot.
open up your /boot/grub/grub,cfg and use that as a template for the kernel you want. Where you can actually find it in the cfg file then copy that over into your 40_custom file in /etc/grub.d, save, update-grub, reboot, cross fingers.
Code:
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/sdb2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-generic-4.19.41--d830e5b3-b05a-479f-9431-8cbd4dc0ccd6' {
savedefault
insmod part_msdos
insmod ext2
set root='hd1,msdos2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos2 --hint-efi=hd1,msdos2 --hint-baremetal=ahci1,msdos2 d830e5b3-b05a-479f-9431-8cbd4dc0ccd6
else
search --no-floppy --fs-uuid --set=root d830e5b3-b05a-479f-9431-8cbd4dc0ccd6
fi
linux /boot/vmlinuz-generic-4.19.41 root=/dev/sdb2
}
the bold is where you'll find the kernel you are looking for to use.
with your last selection saved in your default grub if it does work then it will always default to that kernel unless you pick something different, because it works off of last menu option selected.
if all you want is the latest kernel installed on a particular OS, then just add this, and as stated, it will always be set to whichever menu option you used last, because it will always be selected on next boot. Just by adding this to your grub file.
Code:
GRUB_DEFAULT=saved
#save last distro booted
GRUB_SAVEDEFAULT=true
It is under advance options where that gets tricky because there usually is more than one kernel and mode to pick from and all that is being selected on the boot menu is the option to go into advance options where you then have to move to the kernel and mode yo want, then just go back to the beginning of this post and give that idea a try.
At the grub menu when you first boot select the kernel you want to use. The next boot the same kernel you selected at the first boot should be saved kernel for the default.
this is why we have version numbering system, and should have means for a custom naming scheme. So you can have a back up kernel if you want one. therefore, if you use the same version of kernel then apply the naming scheme to identify it for what it is.
You'll have to read up on that, or wait and hope someone else clues you in on the details more on that. Because I do not roll my own kernels.
“Stand up for Truth even it means standing alone.” Suzy Kassem
"It disturbs me no more to find men base, unjust, or selfish than to see apes mischievous, wolves savage, or the vulture ravenous." Jean-Paul Sartre
“Whenever you deny the hand of Justice, Violence almost always steps in.” Suzy Kassem
"Posting Quotes is not against the law even in Linux Questions, But them that have the power to abuse believe it is.
"If you can abuse your power you have too much." -Marty Rubin
"Government big enough to supply everything you need is big enough to take everything you have." -- often attributed to Thomas Jefferson
Personally, I like the sentiment regardless of the source. RE: Thomas Jefferson
@BW-userx, @colorpurple21859, but I am afraid the next time I will build and install new kernel it will all be overwritten again right?
Yes the default will change, However, as long as grub picks up the new kernel when update-grub is run, it will become the default when selected from the grub menu. The saved default lines in /etc/default/grub are for this when update-grub is run
Last edited by colorpurple21859; 10-01-2020 at 03:47 PM.
I try to setup default grub, I even found similar problem here
So what I do is I set GRUB_DEFAULT in /etc/default/grub to kernel name - FAIL, still boots the exact same kernel #0 from list. Then I didn't give up and try setting GRUB_DEFAULT to number/index regarding to menuentry in /boot/grub/grub.cfg - no luck again.
Here is content of my /etc/default/grub
Does anybody know why this crap doesn't boot the kernal I specify by GRUB_DEFAULT?
PS: of cource I do sudo grub-update after I change that /etc/default/grub file
Grub2 works on the principles of magic, prayer and hope. You can do and hope or you can try and pray, but generally things are just magically happening the way grump2 says it is to happen with no apparent logic or consistency..
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.