How to boot the last used OS each time in grub

So I am new to Fedora, but am a long time Linux user in general… I dual boot on a laptop and like it to have grub just start the last OS used unless I choose specifically. Normally I would just have these two lines in /etc/default/grub


and update grub with

sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

and that is all that is needed. But in Fedora that doesn’t seem to work as expected.

Am I missing something?

1 Like

sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg is not valid since fedora 33. The correct command is sudo grub2-mkconfig -o /boot/grub2/grub.cfg

If you used the command you posted then you need to first remove that grub.cfg file you created then run sudo dnf reinstall grub2-efi* grub2-common to recreate the proper /boot/efi/EFI/fedora/grub.cfg file to allow the system to properly perform updates and see its own updates afterward. With the change of location for the grub.cfg file the system only has a stub file under/boot/efi to point grub to the file under /boot/grub2.

As far as the booting to the last used OS I am not sure how that would be accomplished. The lines you posted cause fedora grub to use the last installed kernel as the default boot. You can change that default to whichever entry you choose, but I don’t know of any way to make it dynamic like you are asking.

Documentation on grub is here


That seemed to fix it… Thank you!

1 Like