How to change Grub 2 default permanently?

16,224

Solution 1

I'm not sure whether there have been any changes/improvements with grubby or anaconda pertaining to this issue. Has anyone tried to follow these guidelines from fedora's wiki page:

Manual changes might however be overwritten with grub2-mkconfig next time the >system is upgraded with anaconda. Some customizations can be placed in /etc/grubd/40_custom or /boot/grub2/custom.cfg and will survive running grub2-mkconfig.

Otherwise, what specifically could be placed in the above-mentioned files that would survive kernel upgrades and/or running grub2-mkconfig?

This is taken from Fedora's Grub wiki page:

Due to grub2-mkconfig (and os-prober) we cannot predict the order of the entries in /boot/grub2/grub.cfg, so we set the default by name/title instead.

Open /etc/default/grub and ensure this line exists:

GRUB_DEFAULT=saved

Apply the change to grub.cfg by running:

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

Now list all possible menu entries

grep "submenu\|^\smenuentry" /boot/grub2/grub.cfg | cut -d "'" -f2

Now set the desired default menu entry

grub2-set-default "<submenu title>><menu entry title>"

Verify the default menu entry

grub2-editenv list

Solution 2

In Fedora you currently can't make this permanently default.

If the kernel is being updated the grubby software used to add Grub2 menu item. And it definitely doesn't pay attention to /etc/default.

Citation from Fedora wiki:

Grubby in Fedora patches the configuration when a kernel update is performed and will try to not make any other changes than what is necessary.

btw, after kernel updated I do package-cleanup --oldkernels --count=1 and grub2-mkconfig -o /boot/grub2/grub.cfg to get rid of old kernels.

Share:
16,224

Related videos on Youtube

Colonel Panic
Author by

Colonel Panic

Updated on September 18, 2022

Comments

  • Colonel Panic
    Colonel Panic over 1 year

    Fedora now uses Grub 2. Whenever it does a kernel upgrade, it loses my default boot option (Windows). How can I fix this?

    I resent Grub 2 over this, because the old Grub respected my choices.