I am customizing GRUB and I want it to remember the last choice on boot but I am unable to make it work. I set GRUB_DEFAULT as saved and uncommented GRUB_SAVEDEFAULT but it still autoselects Linux.
Here is my /etc/default/grub
file:
# GRUB boot loader configuration
GRUB_DEFAULT=saved
GRUB_TIMEOUT='5'
GRUB_DISTRIBUTOR='EndeavourOS'
GRUB_CMDLINE_LINUX_DEFAULT='nowatchdog nvme_load=YES nvidia-drm.modeset=1 loglevel=3'
GRUB_CMDLINE_LINUX=""
# 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
# Set to 'countdown' or 'hidden' to change timeout behavior,
# press ESC key to display menu.
GRUB_TIMEOUT_STYLE=menu
# 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=1920x1080,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-blue/black"
#GRUB_COLOR_HIGHLIGHT="light-cyan/blue"
# Uncomment one of them for the gfx desired, a image background or a gfxtheme
GRUB_BACKGROUND='/usr/share/endeavouros/splash.png'
GRUB_THEME="/usr/share/grub/themes/vimix/theme.txt"
# Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"
# Uncomment to make GRUB remember the last selection. This requires
# setting 'GRUB_DEFAULT=saved' above.
GRUB_SAVEDEFAULT=true
# Uncomment to disable submenus in boot menu
GRUB_DISABLE_SUBMENU='false'
# Probing for other operating systems is disabled for security reasons. Read
# documentation on GRUB_DISABLE_OS_PROBER, if still want to enable this
# functionality install os-prober and uncomment to detect and include other
# operating systems.
#GRUB_DISABLE_OS_PROBER=false
And here is my /boot/grub/grub.cfg
file:
#$
# DO NOT EDIT THIS FILE$
#$
# It is automatically generated by grub-mkconfig using templates$
# from /etc/grub.d and settings from /etc/default/grub$
#$
$
### BEGIN /etc/grub.d/00_header ###$
insmod part_gpt$
insmod part_msdos$
if [ -s $prefix/grubenv ]; then$
load_env$
fi$
if [ "${next_entry}" ] ; then$
set default="${next_entry}"$
set next_entry=$
save_env next_entry$
set boot_once=true$
else$
set default="${saved_entry}"$
fi$
$
if [ x"${feature_menuentry_id}" = xy ]; then$
menuentry_id_option="--id"$
else$
menuentry_id_option=""$
fi$
$
export menuentry_id_option$
$
if [ "${prev_saved_entry}" ]; then$
set saved_entry="${prev_saved_entry}"$
save_env saved_entry$
set prev_saved_entry=$
save_env prev_saved_entry$
set boot_once=true$
fi$
$
function savedefault {$
if [ -z "${boot_once}" ]; then$
saved_entry="${chosen}"$
save_env saved_entry$
fi$
}$
$
function load_video {$
if [ x$feature_all_video_module = xy ]; then$
insmod all_video$
else$
insmod efi_gop$
insmod efi_uga$
insmod ieee1275_fb$
insmod vbe$
insmod vga$
insmod video_bochs$
insmod video_cirrus$
fi$
}$
$
if [ x$feature_default_font_path = xy ] ; then$
font=unicode$
else$
insmod part_gpt$
insmod ext2$
search --no-floppy --fs-uuid --set=root ee8bec65-2ed7-4f37-8350-64767694ac17$
font="/usr/share/grub/unicode.pf2"$
fi$
$
if loadfont $font ; then$
set gfxmode=1920x1080,auto$
load_video$
insmod gfxterm$
set locale_dir=$prefix/locale$
set lang=en_GB$
insmod gettext$
fi$
terminal_input console$
terminal_output gfxterm$
insmod part_gpt$
insmod ext2$
search --no-floppy --fs-uuid --set=root ee8bec65-2ed7-4f37-8350-64767694ac17$
insmod gfxmenu$
loadfont ($root)/usr/share/grub/themes/vimix/dejavu_sans_12.pf2$
loadfont ($root)/usr/share/grub/themes/vimix/dejavu_sans_14.pf2$
loadfont ($root)/usr/share/grub/themes/vimix/dejavu_sans_16.pf2$
loadfont ($root)/usr/share/grub/themes/vimix/dejavu_sans_24.pf2$
loadfont ($root)/usr/share/grub/themes/vimix/dejavu_sans_32.pf2$
loadfont ($root)/usr/share/grub/themes/vimix/dejavu_sans_48.pf2$
loadfont ($root)/usr/share/grub/themes/vimix/terminus-12.pf2$
loadfont ($root)/usr/share/grub/themes/vimix/terminus-14.pf2$
loadfont ($root)/usr/share/grub/themes/vimix/terminus-16.pf2$
loadfont ($root)/usr/share/grub/themes/vimix/terminus-18.pf2$
insmod jpeg$
insmod png$
set theme=($root)/usr/share/grub/themes/vimix/theme.txt$
export theme$
if [ x$feature_timeout_style = xy ] ; then$
set timeout_style=menu$
set timeout=5$
# Fallback normal timeout code in case the timeout_style feature is$
# unavailable.$
else$
set timeout=5$
fi$
### END /etc/grub.d/00_header ###$
$
### BEGIN /etc/grub.d/10_eos_windows ###$
$
menuentry 'Windows 11' --class windows --class os $menuentry_id_option 'osprober-efi-0A76-A923' {$
^Iinsmod part_gpt$
^Iinsmod fat$
^Isearch --no-floppy --fs-uuid --set=root 0A76-A923$
^Ichainloader /efi/Microsoft/Boot/bootmgfw.efi$
}$
### END /etc/grub.d/10_eos_windows ###$
$
### BEGIN /etc/grub.d/11_linux ###$
menuentry 'EndeavourOS Linux' --class endeavouros --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-ee8bec65-2ed7-4f37-8350-64767694ac17' {$
^Isavedefault$
^Iload_video$
^Iset gfxpayload=keep$
^Iinsmod gzio$
^Iinsmod part_gpt$
^Iinsmod ext2$
^Isearch --no-floppy --fs-uuid --set=root ee8bec65-2ed7-4f37-8350-64767694ac17$
^Iecho^I'Loading Linux linux ...'$
^Ilinux^I/boot/vmlinuz-linux root=UUID=ee8bec65-2ed7-4f37-8350-64767694ac17 rw nowatchdog nvme_load=YES nvidia-drm.modeset=1 loglevel=3$
^Iecho^I'Loading initial ramdisk ...'$
^Iinitrd^I/boot/amd-ucode.img /boot/initramfs-linux.img$
}$
submenu 'Advanced options for EndeavourOS Linux' $menuentry_id_option 'gnulinux-advanced-ee8bec65-2ed7-4f37-8350-64767694ac17' --class submenu {$
^Imenuentry 'EndeavourOS Linux, with Linux' --class endeavouros --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-ee8bec65-2ed7-4f37-8350-64767694ac17' {$
^Isavedefault$
^I^Iload_video$
^I^Iset gfxpayload=keep$
^I^Iinsmod gzio$
^I^Iinsmod part_gpt$
^I^Iinsmod ext2$
^I^Isearch --no-floppy --fs-uuid --set=root ee8bec65-2ed7-4f37-8350-64767694ac17$
^I^Iecho^I'Loading Linux linux ...'$
^I^Ilinux^I/boot/vmlinuz-linux root=UUID=ee8bec65-2ed7-4f37-8350-64767694ac17 rw nowatchdog nvme_load=YES nvidia-drm.modeset=1 loglevel=3$
^I^Iecho^I'Loading initial ramdisk ...'$
^I^Iinitrd^I/boot/amd-ucode.img /boot/initramfs-linux.img$
^I}$
^Imenuentry 'EndeavourOS Linux, with Linux (fallback initramfs)' --class endeavouros --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-ee8bec65-2ed7-4f37-8350-64767694ac17' {$
^Isavedefault$
^I^Iload_video$
^I^Iset gfxpayload=keep$
^I^Iinsmod gzio$
^I^Iinsmod part_gpt$
^I^Iinsmod ext2$
^I^Isearch --no-floppy --fs-uuid --set=root ee8bec65-2ed7-4f37-8350-64767694ac17$
^I^Iecho^I'Loading Linux linux ...'$
^I^Ilinux^I/boot/vmlinuz-linux root=UUID=ee8bec65-2ed7-4f37-8350-64767694ac17 rw nowatchdog nvme_load=YES nvidia-drm.modeset=1 loglevel=3$
^I^Iecho^I'Loading initial ramdisk ...'$
^I^Iinitrd^I/boot/amd-ucode.img /boot/initramfs-linux-fallback.img$
^I}$
}$
$
### END /etc/grub.d/11_linux ###$
$
### BEGIN /etc/grub.d/20_linux_xen ###$
### END /etc/grub.d/20_linux_xen ###$
$
### BEGIN /etc/grub.d/30_os-prober ###$
### END /etc/grub.d/30_os-prober ###$
$
### BEGIN /etc/grub.d/31_uefi-firmware ###$
if [ "$grub_platform" = "efi" ]; then$
^Ifwsetup --is-supported$
^Iif [ "$?" = 0 ]; then$
^I^Imenuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' --class efi{$
^I^I^Ifwsetup$
^I^I}$
^Ifi$
fi$
### END /etc/grub.d/31_uefi-firmware ###$
$
### BEGIN /etc/grub.d/35_fwupd ###$
### END /etc/grub.d/35_fwupd ###$
$
### BEGIN /etc/grub.d/40_custom ###$
# This file provides an easy way to add custom menu entries. Simply type the$
# menu entries you want to add after this comment. Be careful not to change$
# the 'exec tail' line above.$
$
menuentry "System restart" --class restart {$
^Iecho "System rebooting..."$
^Ireboot$
}$
$
menuentry "System shutdown" --class shutdown {$
^Iecho "System shutting down..."$
^Ihalt$
}$
### END /etc/grub.d/40_custom ###$
$
### BEGIN /etc/grub.d/41_custom ###$
if [ -f ${config_directory}/custom.cfg ]; then$
source ${config_directory}/custom.cfg$
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then$
source $prefix/custom.cfg$
fi$
### END /etc/grub.d/41_custom ###$
I’ve saved changes with grub-mkconfig -o /boot/grub/grub.cfg
btw.
Thank you.