I’m splitting this off from
Because it is really a different topic from the question there AND what I guessed about this in that thread before looking made it sound harder than it is AND that thread degenerated into an argument about its original question.
For anyone starting here, what we want to know is the correct commands to reboot one time into a different OS, such that when that OS shuts down or reboots the grub default will be back to what it was before we did all this.
In other words make a one time change to the grub default.
We need to set that by name, not by number, because the numbering of the grub menu is not stable enough for this usage. Most of the documentation on grub defaults is by number. There are two different ways to set the default by name, but I need to relearn them.
I don’t yet have a cookbook answer. I’ll experiment a bit more later if no one jumps in to hand us a cook book answer. The google search I did found only answers that are very much Ubuntu specific.
I’m pretty sure you don’t need to do anything to directly or indirectly change /boot/grub2/grub.cfg
. Two different ways to do a one time boot of a different OS are already standard there. You only need to do something with grub2-editenv
followed by the sudo shutdown -r now
I need to experiment a bit later to see what exactly you must do with grub2-editenv
. The best way to do it may depend on how things are currently set. To find that out I use:
sudo cat /boot/grub2/grubenv
On the (non dual boot) system I’m typing on now, that gives:
# GRUB Environment Block
# WARNING: Do not edit this file by tools other than grub-editenv!!!
save_default=true
boot_success=0
saved_entry=40e2b355e289424b842a998c64d8462d-6.5.8-200.fc38.x86_64
boot_indeterminate=2
#########################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
@crazymonkey If you jumped to this new thread with me, what does that command report on your system?
I think to make it cookbook, I also need the output of:
sudo grep -w menuentry /boot/grub2/grub.cfg
Meanwhile if someone else simply knows, please tell us. I also wanted to add that feature to my dual boot system.
The post I marked as the solution contained the key suggestion
sudo grub2-reboot
The actual solution ------------------------------------------------------------
To use that, first I needed:
$ sudo grep -w menuentry /boot/grub2/grub.cfg
menuentry 'Windows Boot Manager (on /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-301F-38B5' {
menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
menuentry "$p/$x" --class=uefi {
$
Copying the title from there, I constructed the commands:
sudo grub2-reboot 'Windows Boot Manager (on /dev/nvme0n1p1)'
sudo shutdown -r now
Executing those two commands caused a reboot into Windows, after which the next reboot came back to Fedora.
Putting those two commands into an icon that can be clicked (for easy switch to Windows) is left as an exercise for the reader.
-------------------------------------------------------------------------------------------
Internally, sudo grub2-reboot 'Windows Boot Manager (on /dev/nvme0n1p1)'
does just sudo grub2-editenv /boot/grub2/grubenv set next_entry='Windows Boot Manager (on /dev/nvme0n1p1)'
That longer, more basic, version is what I was trying to rediscover enough to suggest when I started this thread. But the shorter command first does some extra checks to rule out some reasons the longer command might be unsound. I don’t have a system on which any of those reasons apply, so the two commands are the same. But the shorter one is easier and on some system may be more robust.