Change boot order

I run F42 but share my laptop with someone who runs Windows 11. The laptop boots to F42 by default. Because I’m the more savvy (read “less unsavvy”) of us, and because it’s easier to abort a boot to Windows than it is to abort a boot to F42, I would like make Windows 11 the default. (“Like” is actually to weak a word – the annoyance this causes on top of the stress induced by sharing a lptop in the first place is relationship-threatening!)

I thought all I had to do was hold down F2 while booting up and switch the order of the OSes on the appropriate menu – see the attached photo.

When I make Windows the default option, however, the laptop automatically boots to it, without giving me a chance to select F42.

I’ve found some threads wherein use of the command line is recommended to change the boot order. I find that pretty scary, though. It’s not the command line itself that bothers me – I’ve used it before – but the thought that if I mess up and can’t boot to F42, then I’ll never be able to get back to the command line to fix my mistake. When using Ubuntu (I’m new to Fedora) on other laptops, I’ve always been able to adjust the boot order from the F2 menu.

Any ideas?

If you set the default to Windows in the BIOS then you will need to find the BIOS key to bring up the BIOS boot menu. My systems often use F8.

Do you mean that to boot to Fedora, I will need to use the BIOS key on every boot, and then select the Fedora image?

First, the reason Windows boots without allowing you to choose Linux is that Windows uses hibernation, aka fastboot. For dual booting you need to disable hibernation in Windows. Depending on how you use Linux, you may prefer to either purchase a cheap system for Linux such as one of the many systems being sold at bargain prices (or being given away) because they don’t meet Windows 11 requirements, or to use WSL2 in Windows.

Check out Grub Customizer grub gui tool. It should do what you want.

You might also want to disable fast boot in Windoze.

Please clarify the following: when you boot up you get to see the Grub menu with options for Fedora and Windows?

If yes, then just set

GRUB_DEFAULT=3 #that would be the fourth menu entry

Set this variable in /etc/default/grub

Good advice. It does not regularly get updates, and is hosted by Ubuntu.

Ah… I suppose hibernation explains why booting to Windows immediately after installing a Fedora update (i.e., without first rebooting Fedora) fails.

Actually, I do plan to buy another laptop soon: the only reason I’m sharing now is that my old laptop failed unexpectedly. I will need lots of RAM (like 64 GiB), but there is no reason I need the latest model (my old laptop was 11 years old!). I like your suggestion of getting a good deal on a machine that does not meet W11 specs.

Thank you, that seems simple enough… but what could go wrong? Is there a risk I could make Fedora unbootable by messing up /etc/default/grub? My worry in that case would be that, being unable to boot Fedora, I would have a hard time fixing the error.

I am not quite sure this is correct.
3 active fedora kernels (index 0 - 2) and rescue kernel (index 3)
Then the windows menu entry in the 5th line, but when I run sudo grubby --info=ALL it only displays the index numbers for those 4 entries with nothing shown for the windows entry or the efi setup access.

My grub menu on my dual boot laptop displays 6 lines in the grub boot menu, but the grubby command only shows the index numbers for the 4 fedora kernel entries.

I suspect this is because windows boots with a chainloader command in grub and is not actually an entry created by bls from the .conf files in /boot/loader/entries/.

My laptop shows the windows menu entry in /boot/grub2/grub.cfg as this

$ sudo grep -B2 -A6 -i windows /boot/grub2/grub.cfg

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Boot Manager (on /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-42F8-BF3E' {
	insmod part_gpt
	insmod fat
	search --no-floppy --fs-uuid --set=root 42F8-BF3E
	chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}

With some searching I found this and tested it

Specifically the command shown as grub2-set-default 'Windows 7 (on /dev/sda2)' was of interest.

Using the title in the menuentry line in my grub.cfg file it worked to set the default to windows on my system, and several reboots confirmed that it remains the default.
In my case I used sudo grub2-set-default 'Windows Boot Manager (on /dev/nvme0n1p1)'
Note that the user must use the title shown on the menuentry line in their system /boot/grub2/grub.cfg file.

Resetting the default back to the latest kernel in fedora was accomplished with
sudo grubby --set-default-index=0

Yes that would be required.

You can only chain from grub into Windows if you are not using the bitlocker disk encryption.
Not sure if you can default to booting Windows from grub.

As I understand it, if bitlocker is enabled on windows before linux is installed then the ability to boot windows from the grub menu works (and yes, after updating fedora, a fedora reboot before booting windows ensures that bitlocker remains a non-issue). If bitlocker is enabled after fedora is installed the problem seems to have a work around but requires the bitlocker key.

See my post just above for setting grub to boot windows by default.

1 Like

To make a dual-boot Fedora/Windows machine boot to Windows by default I do:

  1. sudo vim /etc/default/grub
  2. #GRUB_DEFAULT=saved      ⇐ Original value
    GRUB_DEFAULT=$(sed -En "/^menuentry '(Windows Boot Manager [^']*)'.*$/{s//\1/p;q}" /boot/grub2/grub.cfg)
    
  3. sudo grub2-mkconfig -o /boot/grub2/grub.cfg

I like this approach because it is independent of the /dev/…. device node that has the Windows partion.

Test that the sed command works. You may need to adjust it.

sudo sed -En "/^menuentry '(Windows Boot Manager [^']*)'.*$/{s//\1/p;q}" \
   /boot/grub2/grub.cfg

Result (in my case):

Windows Boot Manager (on /dev/nvme0n1p1)

I like the adaptability if that solution, but I’m still worried about what happens if, for example, the regexp fails to match, because the name of the Windows option has changed. Could I be left unable to boot Fedora (and thus unable to fix the sed script) or unable to boot at all?

I don’t think this particular case would prevent Fedora from booting.

However, as a meta-answer, it’s always useful to have a Fedora Live USB handy and a link to the instructions which show you how to use the live environment to repair the bootloader on the installed system:

I believe so. Definitely make sure you have the Bitlocker key available!

I think that you need the key whenever you boot Windows differently from the previous way you booted it. So booting Windows from GRUB for the first time (when your previous Windows boot was direct, not via GRUB) needs the key to be manually entered. But after that, if you always boot Windows from GRUB you shouldn’t need to enter the key every time. The TPM refuses to yield up the key when it sees a change in the boot method.

I’ve never dual booted with Bitlockered Windows though, so this is second-hand info on my part.

If you’re using Bitlocker you must have the key stored somewhere and handy even if you’re not dual booting. I’ve had a colleague desperately calling from field work when her Windows laptop decided to ask for the recovery after a reboot in the middle of the night. Otherwise, you could ask the FBI : Microsoft will be happy to hand them your key when they ask.

1 Like

Don’t be worried. Refer to documentation and do what you need.

I thought it was a hard no way if bitlocker is enabled before or after setting up grub. At least there is a bugzilla asking for a change to grub to trigger the Windows boot without chain loading as that breaks secure boot/TPM2 stuff.

I’m not in a position to test this as the only Windows systems I have have bitlocker disabled.

I was just trying to work up the courage to try robin217’s sed solution. I had a look at /boot/grub2/grub.cfg and am a little bit scared. Not only does it have a lot of code I do not understand, but the comment at the top says DO NOT EDIT THIS FILE.

Since I don’t know what I’m doing, I’m inclined to just leave things as they are and live with the modestly inconvenient boot order for now. If I had a second machine to use as a playground (and I do expect to have such soon), I might give it a try there. But on the main machine that both I and someone else depend on for earning a crust, I don’t want to mess with it for now.

This has been quite educational for me, and I’m grateful to all who replied.