Arch and Windows 11 are on separate SSDs, booted through GRUB. Sometimes, after I power on, Windows starts without ever showing the GRUB menu. Not every time. It has been going on since August, and each time I go into the BIOS and set Boot Option #1 back to GRUB.

It happened again on November 6, so here is the investigation so far. I’ll say up front that I can’t pin down the cause yet. I’ve applied one fix and confirmed it worked once. I worked through this with Claude Code.

Setup and Symptom

  • Motherboard: ASRock A520M Pro4, BIOS P3.90 (AMI, dated 2025-09-30)
  • Arch on an NVMe SSD, Windows 11 on a separate SATA SSD, bootloader is GRUB
  • Windows’ bootmgfw.efi sits on the 4th partition (an ESP) of the Windows SSD

The symptom: I power on and Windows starts without GRUB. If I reboot and press F2, Boot Option #1 is Windows Boot Manager. Set it to GRUB, save, and Arch boots. But if I power off and on again, it sometimes happens again.

The painful part is the middle of the night. My NAS wakes this PC with Wake-on-LAN at around 03:15 to back up Arch. If Windows boots then, the backup fails. According to a record I made on November 5 by matching the NAS log against the Windows event log, there are five nights where Windows booted and the backup failed: 8/7, 10/5, 10/10, 11/2 and 11/5. I haven’t redone that matching this time.

I wrote about dual-booting on this same ASRock board in November 2025 (a post in Japanese). Back then Arch and Windows shared one SSD and the bootloader was systemd-boot. The setup is different now.

The Service That Rewrites the Boot Order

In August I made fix-bootorder.service. When Arch starts, this oneshot service uses efibootmgr to rewrite the boot order (BootOrder) so GRUB comes first.

        [Service]
Type=oneshot
ExecStart=/usr/bin/efibootmgr -o 0001,0000,0004,0005
    

This is the content since October 6. The numbers are the boot entry numbers efibootmgr prints: 0001 is GRUB, 0000 is systemd-boot, 0004 is the generic UEFI OS entry on the NVMe’s ESP. The last one, 0005, was Windows’ number until October.

The service has a limit. It only runs after Arch has started. If Windows gets picked at power-on, the service never gets a chance.

A Failed Fix: Swapping bootmgfw.efi for GRUB

On August 9 I tried to make GRUB start no matter which entry the BIOS picked, by replacing Windows’ bootmgfw.efi with a GRUB binary. I renamed the real one to bootmgfw-original.efi and added a “Windows 11 (real bootmgfw)” entry to the GRUB menu.

It ended in grub rescue. The prefix baked into the copied GRUB was (,gpt1)/grub, a relative path meaning partition 1 of whichever disk it was booted from. Booted from the Windows SSD, there is no /grub there. On August 27 Windows stopped booting, so I put the real file back.

Recording the State Just Before the Rewrite

On October 6 I added an ExecStartPre to the service. It appends efibootmgr -v to /var/log/bootorder-before-fix.log right before the rewrite. Every boot, I now get a record of what NVRAM looked like when Arch started.

        ExecStartPre=-/bin/sh -c '{ echo "=== $(date -Is) ==="; efibootmgr -v; echo; } >> /var/log/bootorder-before-fix.log 2>&1'
    

The 10/6 Experiment: Remove Windows From the Order, Then Put It Back

Windows was entry 0005 then, and the service was removing it from BootOrder. With it removed, I ran poweroff, powered on, and looked at the BIOS with F2: Boot Option #1 was back to Windows Boot Manager.

I added 0005 to the end of the list and repeated the same steps. Boot Option #1 stayed on GRUB. The three power-ons on 10/7 also booted GRUB. The 12 records from the times Arch started between 10/7 and 10/19 all had GRUB first, with Windows still at the end of the list.

My hypothesis at that point: when Windows is missing from BootOrder, the BIOS recreates its entry at power-on and puts it first.

Reading the BIOS Image

I wanted to check that hypothesis against the BIOS itself. I downloaded the P3.90 image from ASRock’s site, split it into modules with uefi-firmware-parser, and read the module that handles boot entries (Bds) after decompiling it to C with Ghidra. Four things came out of what I read:

  • The BIOS only loads the Boot#### entries listed in BootOrder. Entries not listed never get into its internal list
  • The BIOS has a table that maps bootloader paths to display names. \EFI\Microsoft\Boot\bootmgfw.efi becomes Windows Boot Manager, and \EFI\BOOT\BOOTX64.EFI becomes UEFI OS. If that file exists on a disk and no matching entry is in the list, the BIOS creates a new one
  • Entries the BIOS creates get a marker, 00 00 42 4f, at the start of OptionalData. Boot0004 (UEFI OS) and Boot0005 (Windows Boot Manager) on the real machine carried the same marker
  • Whether a new entry goes first or last is decided by a variable called NewOptionPolicy. If it can’t be read, the entry goes first

If I read this correctly, every time the service removes Windows from BootOrder, the BIOS recreates it and puts it first. That fits the 10/6 experiment. But I only read the code. I did not run the BIOS to check. I didn’t find NewOptionPolicy in this PC’s efivars, and I can’t tell whether it exists in a form the OS can’t see. GRUB and systemd-boot for Arch aren’t in the table, so the BIOS doesn’t create them.

The Number Shift on 10/21

Following Windows’ number through the efibootmgr -v output in the log, it was 0005 until 16:56 on October 21, and 0006 in the 19:26 record. At 16:56, 0006 and 0007 were entries for a USB stick I had plugged in. By 19:26, 0005 had become a UEFI OS entry pointing at the 3rd partition of another SSD. I don’t know why the numbers changed. I was adding a GRUB boot entry for another SSD that day, but the record of that command (19:51) is after the numbers had already changed.

The service’s list stayed 0001,0000,0004,0005. It was right while 0005 was Windows. From October 21 on, it points at something that isn’t Windows. So every time the service ran, Windows (0006) dropped out of the list.

This isn’t the first time Windows’ number changed. In August’s investigation Windows was 0006; by October 5 it was 0005, and the service had been failing for about six weeks without my noticing because it named a 0006 that didn’t exist. Hard-coding the numbers is a bad design.

The Record From November 6

At 00:47 I ran poweroff and powered on, and Windows started with no GRUB menu. I set Boot Option #1 to GRUB in the BIOS and saved, and Arch started at 00:50. The service removed Windows from the list at 00:50:30.

At 01:08:05 I ran sudo poweroff. I powered on, opened the F11 boot menu, picked GRUB and started Arch. The BootOrder just before the service ran was 0006,0001,0000,0004,0005, with Windows first (the 01:08:59 entry in the log).

So who rewrote BootOrder in between? This is what I can tell:

  • Arch ran continuously from 00:50:30 to 01:08:05. The only boot-order operations in the journal are the service run and poweroff
  • The boot order at the moment of shutdown is in the records of bootorder-watch, a tool I wrote. It saves the output of efibootmgr every ten minutes and once more at shutdown, and logs differences from the last time. Between the shutdown record at 01:08:07 and the record at the next boot, 01:09:54, no change in the boot order was logged. So at shutdown the boot order was the same 0001,0000,0004,0005 that the service had written
  • It was 39 seconds from power-off to the next Arch boot. Windows could not have run in that time

I think it was the BIOS that changed the boot order to Windows-first, somewhere between the power-off and the next power-on.

The Fix

At 01:15 I added Windows’ 0006 to the service’s ExecStart.

        ExecStart=/usr/bin/efibootmgr -o 0001,0000,0004,0005,0006
    

I ran poweroff at 01:16:03 and powered on at 01:16:43. GRUB started. The record just before the service ran (01:16:55) was 0001,0000,0004,0005,0006, with no change by the BIOS. The off-to-on time was about 40 seconds, the same as the 01:08 run, in which Windows ended up first.

What I Still Don’t Know

  • I’ve confirmed it once. The 10/6 experiment was also one check each way. I’ll look at tonight’s backup results
  • I can’t yet say that keeping Windows in the list prevents this. On the night of 10/10, with Windows at the end of the list (the setup after the 10/6 fix), there is a record of Windows booting. The boot order at that moment wasn’t saved
  • I don’t know what makes the BIOS put Windows first. It could be how long the PC was off, how it was powered off, or something else; the records can’t settle it
  • What triggered the very first Windows boot at 03:30 on 10/5. No progress since the October 7 investigation
  • The actual value of NewOptionPolicy

Looking Back

Today I asked Claude Code to investigate again, and its first answer was “the cause hasn’t been identified.” In fact, the notes I’d written on October 6 and 7 already had the BIOS hypothesis, the experiment results, and even the BIOS image reading. Things moved once it read those notes.

A service that hard-codes numbers stops working silently when the numbers change. bootorder-watch only notifies when “the first entry stops being GRUB,” so it stays quiet even when Windows drops out of the list. Whether to rebuild the service so it orders entries by name, I’ll decide after seeing the backup results.