Confirm our OS is in BIOS or EFI,
1
2
3
4
| # in BIOS system
GRUB_CFG=/boot/grub2/grub.cfg
# in EFI system
GRUB_CFG=/boot/efi/EFI/fedora/grub.cfg |
# in BIOS system
GRUB_CFG=/boot/grub2/grub.cfg
# in EFI system
GRUB_CFG=/boot/efi/EFI/fedora/grub.cfg
Then lookup the booting item id we want to set as default.
If we only want to switch default between Linux kernels,
Else if we want to change default booting item to Windows,
1
| cat $GRUB_CFG | grep Windows |
cat $GRUB_CFG | grep Windows
Read the output, we will find the item, e.g. corresponding to the name, the id is "e528434f2b3e4d7c97d97aa4aabb976e-5.16.7", write it in /etc/default/grub
1
2
| #GRUB_DEFAULT=saved
GRUB_DEFAULT=e528434f2b3e4d7c97d97aa4aabb976e-5.16.7 |
#GRUB_DEFAULT=saved
GRUB_DEFAULT=e528434f2b3e4d7c97d97aa4aabb976e-5.16.7
Finally update grub,
1
2
| grub2-mkconfig -o $GRUB_CFG
#. |
grub2-mkconfig -o $GRUB_CFG
#.
Reboot to see the change.
And in Ubuntu, how to make grub2 remember last choice?
sudo vi /etc/default/grub
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
sudo update-grub |
sudo vi /etc/default/grub
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
sudo update-grub
refer to:
https://docs.fedoraproject.org/en-US/fedora/f35/system-administrators-guide/kernel-module-driver-configuration/Working_with_the_GRUB_2_Boot_Loader/
Fedora 21 改变启动顺序以及grub2 配置技巧
https://askubuntu.com/questions/148662/how-to-get-grub2-to-remember-last-choice