1

I have an HP PC that sets Windows as the first boot partition/device every time you boot Windows. To resolve, I previously have replaced Microsoft's bootmgfw.efi with grubx64.efi in the EFI partition to trick it into thinking that it's booting Windows while in fact it was booting GRUB. The Windows Fall upgrade reset the Windows EFI folder again but now when I replace the bootmgfw.efi file with grubx64.efi, GRUB boots into GRUB when you select Windows (never-ending loop). Linux still boots OK.

Anybody knows how this could be resolved?

Thanks,

blitz
  • 113

1 Answers1

1

The Windows boot loader file, which is normally EFI/Windows/Boot/bootmgfw.efi, must exist on the ESP for Windows to boot. You say you replaced this file with a copy of grubx64.efi, but you don't say what you did with the original file. If you overwrote it, then Windows can't boot unless/until you restore the original file. (You can restore the file to another name, as described shortly.) If you've got a backup, you can restore it from that. If not, then I suggest you ask on a Windows forum about restoring the original file. You can then start over, being more careful with that original file.

If you renamed the original file, you should be able to edit GRUB's configuration to launch the file using its new name. The best way to do this, if you stick with GRUB, is to edit /etc/grub.d/40_custom to include something like this:

menuentry "Windows" {
    insmod part_gpt
    insmod chain
    set root='(hd0,gpt1)'
    chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}

You must change the partition ID [(hd0,gpt1) -- that is, the first partition (gpt1) on the first hard disk (hd0)] in this example to match your ESP. You must also change the boot loader filename, which this example shows as the default filename, which of course you've changed.

After creating or editing /etc/grub/40_custom, you must type sudo update-grub. This transfers these changes, along with other GRUB settings, to /boot/grub/grub.cfg. (You could edit that file directly, but then your edits will be wiped out whenever GRUB updates its configuration, such as after an automatic kernel update.)

Rod Smith
  • 45,120
  • 7
  • 66
  • 108