Change default boot menu entry

GRUB2 boot menu on my system has the following entries (excrept from /boot/grub2/grub.cfg):

  • menuentry ‘openSUSE Leap 42.1’ --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option ‘gnulinux-simple-70bf5da6-46d4-4196-b042-f58de7a147c8’
  • submenu ‘Advanced options for openSUSE Leap 42.1’ --hotkey=1 $menuentry_id_option ‘gnulinux-advanced-70bf5da6-46d4-4196-b042-f58de7a147c8’
    [LIST]
  • menuentry ‘openSUSE Leap 42.1, with Linux 4.8.0-rc6.bd0b841f-vanilla’ --hotkey=2 --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option ‘gnulinux-4.8.0-rc6.bd0b841f-vanilla-advanced-70bf5da6-46d4-4196-b042-f58de7a147c8’
  • menuentry ‘openSUSE Leap 42.1, with Linux 4.8.0-rc4.bd0b841f-vanilla’ --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option ‘gnulinux-4.8.0-rc4.bd0b841f-vanilla-advanced-70bf5da6-46d4-4196-b042-f58de7a147c8’

[/LIST]

I’m trying to configure GRUB2 so that my system automatically boots to kernel 4.8.0-rc4 (the second entry in the first submenu).

I’ve tried the following methods:

Method 1:

# grub2-set-default 'gnulinux-advanced-70bf5da6-46d4-4196-b042-f58de7a147c8>gnulinux-4.8.0-rc4.bd0b841f-vanilla-advanced-70bf5da6-46d4-4196-b042-f58de7a147c'
# grub2-mkconfig -o /boot/grub2/grub.cfg

Method 2:
Edit /etc/default/grub and set:
GRUB_DEFAULT=0>1
followed by:


# grub2-mkconfig -o /boot/grub2/grub.cfg

Method 3:
Same as method 2, except set
GRUB_DEFAULT=“0>1”

Method 4:
Same as method 2, except I thought maybe all the references I found online are wrong about menu entries being zero-based and set:
GRUB_DEFAULT=“1>2”

Method 5:
Same as method 2, except set
GRUB_DEFAULT=saved
then on next boot choose the desired kernel manually, and after that reboot once more.

Method 6:
Use the Boot loader configuration in YaST2 to choose the desired default entry from the drop-down.

None of these methods have achieved what I want. When I reboot the system and don’t choose anything from the boot menu, system boots to the “wrong” kernel (4.8.0-rc6).

What else could I try?

What seems like redundancy might be in order, here.

Use method “6” again. (Pay attention where you are installing Grub to, so you can do the following):

After saving and exiting, drop to CLI.

grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install /dev/sd**XN**

where X is the device and N is the partition where Grub is installed. If in the MBR, then just sdX

I use the Yast2 Bootloader to set my default boot entry.

Click on the Bootloader Options tab
Click on the bar with the dropdown arrow below Default Boot Section
Choose your selection from the list and click on the OK
button
Reboot your system.

One character is missing from the second UUID. This requires GRUB_DEFAULT=saved and we do not know what was the value when you tried it (it is written in manual). This does not need grub-mkconfig because it does not change anything in grub.cfg.

GRUB_DEFAULT=0>1

This sets GRUB_DEFAULT to plain 0.

GRUB_DEFAULT=“0>1”

Top level submenu number is 1, not 0.

GRUB_DEFAULT=“1>2”

Submenu 1 does not have menu item 2 (at least you did not show it)

GRUB_DEFAULT=saved

This returns us to typo made in step 1 when setting default value. Under some conditions grub cannot write to environment file during boot, so you are left with wrong value.

Use the Boot loader configuration in YaST2 to choose the desired default entry from the drop-down.

Well, if this does not work we have a bug. In which case you need to provide more information. Make available grub.cfg (upload to http://susepaste.org) as well as output of “grub2-editenv - list”

grub-install is absolutely redundant in this case; it has nothing to do with changes in the content of grub.cfg.

Today is much better day than yesterday. All the following methods now work:

Method 1. Write the desired entry to /etc/default/grub directly:
GRUB_DEFAULT=“1>1”

and then run

grub2-mkconfig -o /boot/grub2/grub.cfg

What I was confused about yesterday was that the submenu “Advanced options for openSUSE” counts not as first (0-th) submenu but as second (1-th) menu point from the top.

Method 2: have GRUB_DEFAULT=saved in /etc/default/grub and use grub2-set-default to set the desired menu entry.

grub2-set-default  'gnulinux-advanced-70bf5da6-46d4-4196-b042-f58de7a147c8>gnulinux-4.8.0-rc4.bd0b841f-vanilla-advanced-70bf5da6-46d4-4196-b042-f58de7a147c8'

Likely this didn’t work yesterday because of typo.

Method 3: Use YaST2: System > Boot loader > Bootloader options. I don’t know why this didn’t work yesterday.

It often does not write the bootloader first time around, which is why I suggested use Yast Bootloader, then follow it with the CLI commands.

This has been going on – off & on – at least as far back as v13.1.

In general using menu entry IDs is recommended - they are more stable than menu entry numbers.

OP didn’t say how the grub config he showed was created. On my 42.2 system grub2-mkconfig always list the kernels in lexicographic order, which would place rc4 before rc6.

Anyway, his strategy 6 seems to be the best approach. On my system, after I use YaST to set the default bootloader, I observe that:
On the first screen with the main menu, the middle entry is highlighted instead of the top one.
If I press enter or let the timeout expire, the sub menu is displayed with my default kernel highlighted instead of the top kernel.
If I press enter or let the timeout expire, my default kernel is booted.

This seems to be almost what OP wanted. You CAN edit grub.cfg, but the next time a kernel is installed, grub2-mkconfig will again order the entries lexicographically.