Help setting default grub entry

Looks like there is no more grub-customizer. :thinking: So I need a new way to select default grub entry to initramfs, because my laptop wont boot up with the current default grub entry.

Most method I found on the internet require the use of grub-customizer. But I did found modifying GRUB_DEFAULT in /etc/default/grub to ID>ID should do it.

I modify it to GRUB_DEFAULT=1>1, this is supposed to select second entry, and then select second sub-entry. :grinning: At first boot it does work that way. :disappointed: But now it will select second entry then select first entry regardless what the second number in GRUB_DEFAULT is.

What is the best way to do it?

You can use this for the first 10 line in /etc/default/grub

GRUB_DEFAULT=saved #this will make the default the saved boot entry
GRUB_TIMEOUT=5 #this sets the time to proceed to boot
GRUB_TIMEOUT_STYLE=hidden
GRUB_DISTRIBUTOR="Manjaro"
GRUB_CMDLINE_LINUX_DEFAULT="quiet udev.log_priority=3" #this make sure you keep as you have it now
GRUB_CMDLINE_LINUX=""

# If you want to enable the save default function, uncomment the following
# line, and set GRUB_DEFAULT to saved.
GRUB_SAVEDEFAULT=true #this instructs grub to actually save the last entry you boot from 

Run sudo update-grub after modifications

2 Likes

my config looks like this

GRUB_DEFAULT='Advanced options for Manjaro Linux>Manjaro Linux (Kernel: 5.9.16-1-MANJARO x64)'
#GRUB_SAVEDEFAULT=true
1 Like

so with this method, same thing happened like last time. After I restarted and selected my boot entry, the next restart, it does choose my saved boot entry, which is First entry > Second sub-entry,

I restarted it couple of times and it works just fine.
But the next day, just like my first solution, it will choose First entry > First sub-entry, which does not boot properly anymore.
(Actually, I don’t know which sub-entry it chosen. But it’s definitely not booting properly. Only the second sub-entry, the one with initramfs that worked)

I wonder if this is a bug?

I probably should have posted my /etc/default/grub, my bad.

But I admit, I didn’t set GRUB_CMDLINE_LINUX_DEFAULT exactly like the example. I keep the default since it already had udev.log_priority=3. I wonder if that’s what causing it?

I will remove the splash apparmor=1 security=apparmor, sudo update-grub, then set my default again. If tomorrow it still works properly, I will mark this as solved.

GRUB_DEFAULT=saved
GRUB_TIMEOUT="5"
GRUB_TIMEOUT_STYLE="hidden"
GRUB_DISTRIBUTOR="Manjaro"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash apparmor=1 security=apparmor udev.log_priority=3"
GRUB_CMDLINE_LINUX=""

# If you want to enable the save default function, uncomment the following
# line, and set GRUB_DEFAULT to saved.
# GRUB_SAVEDEFAULT="false"
GRUB_SAVEDEFAULT=true

# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt part_msdos"

# Uncomment to enable booting from LUKS encrypted devices
#GRUB_ENABLE_CRYPTODISK="y"

# Uncomment to use basic console
GRUB_TERMINAL_INPUT="console"

# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT="console"

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command 'videoinfo'
GRUB_GFXMODE="auto"

# Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX="keep"

# Uncomment if you want GRUB to pass to the Linux kernel the old parameter
# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
#GRUB_DISABLE_LINUX_UUID="true"

# Uncomment to disable generation of recovery mode menu entries
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-gray/black"
GRUB_COLOR_HIGHLIGHT="green/black"

# Uncomment one of them for the gfx desired, a image background or a gfxtheme
#GRUB_BACKGROUND="/usr/share/grub/background.png"
GRUB_THEME="/usr/share/grub/themes/manjaro/theme.txt"

# Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"

change:

GRUB_DEFAULT=0 // <-- as example
GRUB_SAVEDEFAULT="false" // <--- important

That is my very first method.
GRUB_SAVEDEFAULT="false" which is now commented.

I am not sure if use of GRUB_DEFAULT=1>1 will work
GNU GRUB Manual 2.04: Simple configuration only mentions use of a single number
so GRUB_DEFAULT=1 will boot the 2nd ‘menuentry’ which should be the fallback initramfs
for the latest installed kernel

use this command to check the list

sudo grep ^menuentry /boot/grub/grub.cfg |cut -d "'" -f2

This is not a good solution for booting later ‘menuentry’ options as the ID number is more likely to change when a kernel is added or removed


I have not seen the Advanced menu included the name, as in post by @Hagen
only simpler examples of using menuentry name, lik this:
GRUB_DEFAULT="Manjaro Linux (Kernel: 5.10.7-3-MANJARO x64 - fallback initramfs)"

This is good to keep boot locked to one option, but /etc/default/grub would have to be edited when the kernel version number changes


I use the same options as @bogdancovaciu
(GRUB_DEFAULT=saved and GRUB_SAVEDEFAULT=true)

But I add an option to GRUB to disable the Advanced menu, so It is easier to see the boot options and change which one I want to use

echo `GRUB_DISABLE_SUBMENU=true` | sudo tee --append /etc/default/grub
1 Like

Wow, that is a lot of useful information.

Yesterday I tried using the same example as Mr Hagen.

Like this…
GRUB_DEFAULT='Advanced options for Manjaro Linux>Manjaro Linux (Kernel: 5.9.16-1-MANJARO x64 - fallback initramfs)'

I just tested today and fortunately it still works.


This is very useful piece of information.
With that in mind I think my final configuration is like this:

GRUB_DEFAULT=1
GRUB_DISABLE_SUBMENU=true

as fallback initramfs always second entry.

Big thanks to you sir!
and for everyone else too.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.