Grub2 automatically linux latest on default boot

//edit

I basically have the problem this guy had: https://www.reddit.com/r/btrfs/comments/itwded/grub_booting_into_previous_snapshot_how_to_change/

and now I am stuck and dont know how to fix it.

my grub option when I press e, show something like this:

	search --no-floppy --fs-uuid --set=root 317d6071-2258-4318-b5a9-b1291713852a
	echo	'Loading Linux linux ...'
	linux	/timeshift-btrfs/snapshots/2024-05-23_15-15-49/@/boot/vmlinuz-linux root=UUID=317d6071-2258-4318-b5a9-b1291713852a rw rootflags=subvol=timeshift-btrfs/snapshots/2024-05-23_15-15-49/@  nowatchdog nvme_load=YES nvidia_drm.modeset=1 loglevel=3 pcie_port_pm=off pcie_aspm.policy=performance
	echo	'Loading initial ramdisk ...'
	initrd	/timeshift-btrfs/snapshots/2024-05-23_15-15-49/@/boot/initramfs-linux.img

but I want it not to look at the snapshot folder. Can I simply put back @/boot/initramfs-linux.img and @/boot/vmlinuz-linux in there and I will be fine again? (I guess making a mistake here could break my system).


Hey!

Somehow I cannot get the bootoader to start the latest kernel as the default option.

I’ve tried removing the lts kernel completely

pacman -Q | grep linux
archlinux-appstream-data 20240415-1
archlinux-keyring 20240520-1
lib32-util-linux 2.40.1-1
linux 6.9.1.arch1-2
linux-api-headers 6.8-1
linux-firmware 20240510.b9d2bf23-1
linux-firmware-whence 20240510.b9d2bf23-1
linux-headers 6.9.1.arch1-2
util-linux 2.40.1-1
util-linux-libs 2.40.1-1

and run sudo grub-mkconfig -o /boot/grub/grub.cfg:

Generating grub configuration file ...
Found background: /usr/share/endeavouros/splash.png
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot:  initramfs-linux-fallback.img
^AWarning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
Detecting snapshots ...
Found snapshot: 2024-05-23 21:50:30 | timeshift-btrfs/snapshots/2024-05-23_21-50-30/@ | ondemand                       | {timeshift-autosnap} {created before upgrade} |
Found snapshot: 2024-05-23 21:26:11 | timeshift-btrfs/snapshots/2024-05-23_21-26-11/@ | boot                           | N/A                                           |
Found snapshot: 2024-05-23 21:00:00 | timeshift-btrfs/snapshots/2024-05-23_21-00-00/@ | hourly                         | N/A                                           |
Found snapshot: 2024-05-23 19:41:19 | timeshift-btrfs/snapshots/2024-05-23_19-41-19/@ | boot                           | N/A                                           |
Found snapshot: 2024-05-23 19:32:06 | timeshift-btrfs/snapshots/2024-05-23_19-32-06/@ | ondemand hourly                | {timeshift-autosnap} {created before upgrade} |
Found snapshot: 2024-05-23 17:13:19 | timeshift-btrfs/snapshots/2024-05-23_17-13-19/@ | ondemand hourly                | {timeshift-autosnap} {created before upgrade} |
Found snapshot: 2024-05-23 15:15:49 | timeshift-btrfs/snapshots/2024-05-23_15-15-49/@ | ondemand daily                 | N/A                                           |
Found snapshot: 2024-05-21 22:24:57 | timeshift-btrfs/snapshots/2024-05-23_16-03-23/@ | ondemand hourly                | Before restoring '2024-05-23 15:15:49'        |
Found snapshot: 2024-05-21 22:14:41 | timeshift-btrfs/snapshots/2024-05-21_22-24-57/@ | ondemand                       | Before restoring '2024-05-21 22:00:00'        |
Found snapshot: 2024-05-21 22:14:24 | timeshift-btrfs/snapshots/2024-05-21_22-14-24/@ | ondemand                       | AFTER nvidia-lts kernel-lts                   |
Found snapshot: 2024-05-21 22:03:51 | timeshift-btrfs/snapshots/2024-05-21_22-03-51/@ | ondemand hourly weekly monthly | BEFORE nvidia-lts kernel-lts                  |
Found snapshot: 2024-05-21 19:04:55 | timeshift-btrfs/snapshots/2024-05-21_19-04-55/@ | ondemand                       | N/A                                           |
Found snapshot: 2024-05-20 01:19:47 | timeshift-btrfs/snapshots/2024-05-20_01-19-47/@ | ondemand                       | N/A                                           |
Found 13 snapshot(s)
Unmount /tmp/grub-btrfs.PVR1GtwWzd .. Success
done

yet its still the “default” selected entry is a entry which wants to load the non existent lts kernel. It will of course fail and I have to go manually to the “advanced” menu and select the normal linux kernel. (the lts and fallback-lts kernel are also showing up there still… which I dont understand)

/etc/default/grub

# GRUB boot loader configuration

GRUB_DEFAULT='0'
GRUB_TIMEOUT='5'
GRUB_DISTRIBUTOR='EndeavourOS'
GRUB_CMDLINE_LINUX_DEFAULT='nowatchdog nvme_load=YES nvidia_drm.modeset=1 loglevel=3 pcie_port_pm=off pcie_aspm.policy=performance'
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=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="/path/to/gfxtheme"

# 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
GRUB_EARLY_INITRD_LINUX_STOCK=''

/boot/grub/grub.cfg

#
# 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="0"
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 btrfs
search --no-floppy --fs-uuid --set=root 317d6071-2258-4318-b5a9-b1291713852a
    font="/timeshift-btrfs/snapshots/2024-05-23_15-15-49/@/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=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 btrfs
search --no-floppy --fs-uuid --set=root 317d6071-2258-4318-b5a9-b1291713852a
insmod png
background_image -m stretch /timeshift-btrfs/snapshots/2024-05-23_15-15-49/@/usr/share/endeavouros/splash.png
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_linux ###
menuentry 'EndeavourOS Linux' --class endeavouros --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-317d6071-2258-4318-b5a9-b1291713852a' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod btrfs
	search --no-floppy --fs-uuid --set=root 317d6071-2258-4318-b5a9-b1291713852a
	echo	'Loading Linux linux ...'
	linux	/timeshift-btrfs/snapshots/2024-05-23_15-15-49/@/boot/vmlinuz-linux root=UUID=317d6071-2258-4318-b5a9-b1291713852a rw rootflags=subvol=timeshift-btrfs/snapshots/2024-05-23_15-15-49/@  nowatchdog nvme_load=YES nvidia_drm.modeset=1 loglevel=3 pcie_port_pm=off pcie_aspm.policy=performance
	echo	'Loading initial ramdisk ...'
	initrd	/timeshift-btrfs/snapshots/2024-05-23_15-15-49/@/boot/initramfs-linux.img
}
submenu 'Advanced options for EndeavourOS Linux' $menuentry_id_option 'gnulinux-advanced-317d6071-2258-4318-b5a9-b1291713852a' {
	menuentry 'EndeavourOS Linux, with Linux linux' --class endeavouros --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-317d6071-2258-4318-b5a9-b1291713852a' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod btrfs
		search --no-floppy --fs-uuid --set=root 317d6071-2258-4318-b5a9-b1291713852a
		echo	'Loading Linux linux ...'
		linux	/timeshift-btrfs/snapshots/2024-05-23_15-15-49/@/boot/vmlinuz-linux root=UUID=317d6071-2258-4318-b5a9-b1291713852a rw rootflags=subvol=timeshift-btrfs/snapshots/2024-05-23_15-15-49/@  nowatchdog nvme_load=YES nvidia_drm.modeset=1 loglevel=3 pcie_port_pm=off pcie_aspm.policy=performance
		echo	'Loading initial ramdisk ...'
		initrd	/timeshift-btrfs/snapshots/2024-05-23_15-15-49/@/boot/initramfs-linux.img
	}
	menuentry 'EndeavourOS Linux, with Linux linux (fallback initramfs)' --class endeavouros --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-317d6071-2258-4318-b5a9-b1291713852a' {
		load_video
		set gfxpayload=keep
		insmod gzio
		insmod part_gpt
		insmod btrfs
		search --no-floppy --fs-uuid --set=root 317d6071-2258-4318-b5a9-b1291713852a
		echo	'Loading Linux linux ...'
		linux	/timeshift-btrfs/snapshots/2024-05-23_15-15-49/@/boot/vmlinuz-linux root=UUID=317d6071-2258-4318-b5a9-b1291713852a rw rootflags=subvol=timeshift-btrfs/snapshots/2024-05-23_15-15-49/@  nowatchdog nvme_load=YES nvidia_drm.modeset=1 loglevel=3 pcie_port_pm=off pcie_aspm.policy=performance
		echo	'Loading initial ramdisk ...'
		initrd	/timeshift-btrfs/snapshots/2024-05-23_15-15-49/@/boot/initramfs-linux-fallback.img
	}
}

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

### BEGIN /etc/grub.d/15_ostree ###
### END /etc/grub.d/15_ostree ###

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

### BEGIN /etc/grub.d/25_bli ###
if [ "$grub_platform" = "efi" ]; then
  insmod bli
fi
### END /etc/grub.d/25_bli ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
if [ "$grub_platform" = "efi" ]; then
	fwsetup --is-supported
	if [ "$?" = 0 ]; then
		menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
			fwsetup
		}
	fi
fi
### END /etc/grub.d/30_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.
### 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 ###

### BEGIN /etc/grub.d/41_snapshots-btrfs ###
if [ ! -e "${prefix}/grub-btrfs.cfg" ]; then
echo ""
else
submenu 'EndeavourOS snapshots' {
    configfile "${prefix}/grub-btrfs.cfg"
}
fi
### END /etc/grub.d/41_snapshots-btrfs ###

It seems that “timeshift” (which I set to on boot) does some magic here?

I tried:

GRUB_DEFAULT='2'
GRUB_TOP_LEVEL="/boot/vmlinuz-linux"

both had no effect, so I reverted it. (I did do a sudo grub-mkconfig -o /boot/grub/grub.cfg before rebooting)

I’m running btrfs.

Anyone know what could cause this?

Maybe because I jumped to a older snapshot previously and its somehow “stuck” on this step instead of normal looking at /boo/…/kernel?

Yes, that is what happens when you boot into a snapshot and then do something that invokes grub-mkconfig.

That is why when you boot into a snapshot, the only thing you should do is restore the snapshot and then reboot.

To fix it, you either need to manually edit the files to correct, values, boot into them and then re-run grub-mkconfig or chroot into the correct subvolume and do the same.

1 Like

My bad. But now I know.

To fix it, you either need to manually edit the files to correct, values, boot into them and then re-run grub-mkconfig or chroot into the correct subvolume and do the same.

What do you mean by edit the files (which files, the /boot/grub/grub.cfg I reckon?) and values (what are correct values here?)

Fixed it by booting into a good snapshot (which had unaltered grub.cfg values), then rebooted immediately (after login).
Snapshots and default option are good now.

Thanks for the hint. :slight_smile:

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