View previous topic :: View next topic |
Author |
Message |
psycho Guru


Joined: 22 Jun 2007 Posts: 553 Location: New Zealand
|
Posted: Wed May 19, 2021 10:30 am Post subject: Why can't GRUB chainload Windows Boot Manager? |
|
|
I've seen lots of claims that this can be done, but I can't get it to work.
* I can boot Gentoo (GRUB) with no problems from the BIOS EFI boot menu
* I can boot Windows with no problems from the BIOS EFI boot menu
I don't want to go into the BIOS menu to choose one or the other, however: in the past when I've dual-booted (on MBR setups) I've always used a "chainloader" entry so that BIOS loads GRUB, then GRUB allows me to choose Gentoo or Windows. From the wiki and lots of forum posts it looks like this *should* be possible, but it never works: it does launch the Windows Boot Manager (or at least I assume the big "Windows Boot Manager" banner across the top of the screen indicates that the bootmgfw.efi was found and launched and attempted to do its thing)...but under that it just says "Windows failed to start" and claims that "File: \EFI\Microsoft\Boot\BCD" is corrupted.
Normally I'd be thinking grub-install screwed something up and I need to get a Windows installer and attempt to repair the Windows boot stuff...but hang on a minute...how can that be, when Windows boots perfectly well (using the same EFI stuff) from the BIOS menu? If it can boot with no errors from BIOS, why can't GRUB chainload it? Has anyone seen this before or have some idea what's going on? |
|
Back to top |
|
 |
alamahant Advocate

Joined: 23 Mar 2019 Posts: 3961
|
Posted: Wed May 19, 2021 10:52 am Post subject: |
|
|
It used to boot just fine via grub when I had windows installed
You can use
efibootmgr
efibootmgr -n <boot-id-of-next-boot> _________________
 |
|
Back to top |
|
 |
Ralphred l33t

Joined: 31 Dec 2013 Posts: 800
|
Posted: Wed May 19, 2021 11:01 am Post subject: |
|
|
Separate disks for doze and gentoo? |
|
Back to top |
|
 |
Goverp Advocate


Joined: 07 Mar 2007 Posts: 2298
|
Posted: Wed May 19, 2021 11:32 am Post subject: Re: Why can't GRUB chainload Windows Boot Manager? |
|
|
psycho wrote: | ...
Normally I'd be thinking grub-install screwed something up and I need to get a Windows installer and attempt to repair the Windows boot stuff...but hang on a minute...how can that be, when Windows boots perfectly well (using the same EFI stuff) from the BIOS menu? If it can boot with no errors from BIOS, why can't GRUB chainload it? Has anyone seen this before or have some idea what's going on? |
I've had this problem, and used Windows tools to repair, which gave me what appears to be the contents of the EFI/ windows stuff moved up to the parent directory, very messy but it boots. (
My guess as the problem is that grub-mkinstall and os-prober have between them chainload the wrong thing; probably the Windows boot loader or the system boot loader, rather than the Windows system, To clarify (!):
EFI expects your BIOS maker to put a boot loader at /EFI/boot/bootx64.efi (Mine also has one at /EFI/boot/HP) - this is the default and fallback if all else fails.
Windows should put its own bootloader at /EFI/Microsoft/Boot (and I think another one at /EFI/Microsoft/Recovery) - I guess this points at something in the Windows partition
Grub should put its into /EFI/boot/gentoo/grubx64.efi, and it can point anywhere. Grub uses efibootmgr to write a new boot loader definition in EFIvars pointing at this. That should leave at least one or two of the above available. However that list is NOT necessarily the list of BIOS boot options; it's priority order by which BIOS tries to find a working boot loader (hence the fallback default); the list of BIOS boot options is maintained by the BIOS configuration tool (Hit F2 or DEL at boot to enter) and appears sometimes to be this list, but sometimes some other list, perhaps manually configured. At least, this is my reading of the EFI documentation.
Not sure if that helps! _________________ Greybeard |
|
Back to top |
|
 |
Irre Guru

Joined: 09 Nov 2013 Posts: 434 Location: Stockholm
|
|
Back to top |
|
 |
psycho Guru


Joined: 22 Jun 2007 Posts: 553 Location: New Zealand
|
Posted: Thu May 20, 2021 3:48 am Post subject: |
|
|
Thanks for these suggestions, and for that detailed explanation Goverp. I would indeed prefer to have Windows on its own disk, but don't have that option: it's a small laptop with a single NVMe slot, so I replaced that with one huge NVMe and just have to put all the operating systems on that one disk.
I still don't see why, if the BIOS can (and clearly it can) persuade Windows to start with whatever files are there under EFI right now, it's not possible for GRUB to kick off the same process...it feels intuitively as though there ought to be a way...however I'm encouraged by the fact that you (Goverp) have seen something similar and solved it by doing the Windows boot repair thing, which was probably going to be the next thing I tried anyway...so I'll give that a shot. If that works I'll be happy.
Not sure about grub2win...looks interesting but I can't tell from the project page what it actually does (is it basically a GRUB fork that's installed from Windows...?)...anyway I'd prefer to stick with the existing tools if I can get them working. In fact I'll probably just use the BIOS boot menu if windows boot repair doesn't do the trick...but I'm more hopeful now that it will. Can't try until later tonight but will mark the thread solved if it works.
[Edit] I don't understand the efibootmgr thing either: are you saying I can call that somehow from the Windows entry in my grub.cfg menu? If so I'll give that a shot first. |
|
Back to top |
|
 |
alamahant Advocate

Joined: 23 Mar 2019 Posts: 3961
|
Posted: Thu May 20, 2021 9:33 am Post subject: |
|
|
Quote: | [Edit] I don't understand the efibootmgr thing either: are you saying I can call that somehow from the Windows entry in my grub.cfg menu? If so I'll give that a shot first.
|
No when you are in gentoo you run
Code: |
efibootmgr#### to see the boot entries
efibootmgr -o <gentoo-id>,<windows-id> ### to make sure gentoo is the default first one to boot
efibootmgr -n <windows-id> #### to pick up next boot
reboot
|
It will take you directly to windows bypassing grub. _________________
 |
|
Back to top |
|
 |
psycho Guru


Joined: 22 Jun 2007 Posts: 553 Location: New Zealand
|
Posted: Thu May 20, 2021 10:53 am Post subject: |
|
|
Oh, OK. Well, I guess that's a last-resort GRUB option then: I could set up a very fast-booting, minimal kernel as a Gentoo entry that claims to be "Windows" but really launches Linux just to immediately call efibootmgr and launch Windows. Sounds like a drag though...I'll probably just use the BIOS boot menu as it's not much slower than GRUB (and almost certainly faster than a Gentoo->Windows double-boot drama), if it comes to that. I'm hoping the Windows boot repair thing will do the trick though...have run out of time to try that tonight, but will give it a shot sometime in the next few days. |
|
Back to top |
|
 |
alamahant Advocate

Joined: 23 Mar 2019 Posts: 3961
|
Posted: Thu May 20, 2021 10:56 am Post subject: |
|
|
It means that by default your system will boot into Gentoo.
And if you need to boot windows you will need this efibootmgr command run from inside gentoo.
 _________________
 |
|
Back to top |
|
 |
Goverp Advocate


Joined: 07 Mar 2007 Posts: 2298
|
Posted: Thu May 20, 2021 4:23 pm Post subject: |
|
|
psycho wrote: | Oh, OK. Well, I guess that's a last-resort GRUB option then: I could set up a very fast-booting, minimal kernel as a Gentoo entry that claims to be "Windows" but really launches Linux just to immediately call efibootmgr and launch Windows. ... |
Do you have a working efibootmgr entry for booting Windows? Otherwise I suspect this may just kick the can down the road - i.e. my guess is you'll get the message about corrupt BCD.
How have you built your grub.cfg? And (a) what's its entry for Windows, and (b) what does the EFI boot menu say is its entry for Windows (c) what are your efibootmgr entries?
And for general info: Secure Boot? Compatibility Mode? and what's the disk's partition table? _________________ Greybeard |
|
Back to top |
|
 |
figueroa Advocate


Joined: 14 Aug 2005 Posts: 3026 Location: Edge of marsh USA
|
Posted: Fri May 21, 2021 3:16 am Post subject: |
|
|
The subject of this thread seems misleading. GRUB chainloads GRUB. So, if you have GRUB installed and booting on SDA and also installed on SDB, GRUB on SDA can chainlocal the GRUB on SDB. GRUB cannot chainload a foreign bootloader. GRUB can load (but not chainload) almost any operating system.
Code: | menuentry "Chainload Grub on /dev/sdb" {
set root=(hd1)
chainloader +1
} |
I think I got that right. It works.  _________________ Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi -wayland |
|
Back to top |
|
 |
psycho Guru


Joined: 22 Jun 2007 Posts: 553 Location: New Zealand
|
Posted: Fri May 21, 2021 10:24 am Post subject: |
|
|
Windows boot repair failed with some "cannot repair" message. Manually attempting to fix it with bcdboot reported success (something like "all UEFI files created")...but I'm still in the same boat, with Windows booting perfectly well from the BIOS (and from alamahant's set-the-next-EFI-then-reboot trick...again, that worked with no problems, showing that there's actually nothing wrong with the EFI stuff)...however GRUB won't launch it. Maybe it's simply a grub.cfg misconfiguration...though I've tried at least a dozen variants and as I said, this one does successfully launch the Windows Boot Manager...only to have it crash with "Windows failed to start".
Here's my current grub.cfg entry: Code: | menuentry 'Windows' --class windows {
insmod chain
chainloader (hd0,1)/EFI/Microsoft/Boot/bootmgfw.efi
} |
|
|
Back to top |
|
 |
alamahant Advocate

Joined: 23 Mar 2019 Posts: 3961
|
Posted: Fri May 21, 2021 10:44 am Post subject: |
|
|
Please try
GRUB_PRELOAD_MODULES="part_msdos part_gpt"
in /etc/default/grub
and update grub.
You do use os-prober with grub no?
I hope you dont create the grub entries manually.......
Oh my God you do....
Dont!!!!!
Please try with os-prober and the above modules and it will work just fine.
At least try appending
Code: |
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
insmod part_gpt
|
to your entry and see what happens.
 _________________
 |
|
Back to top |
|
 |
psycho Guru


Joined: 22 Jun 2007 Posts: 553 Location: New Zealand
|
Posted: Fri May 21, 2021 11:51 am Post subject: |
|
|
os-prober was one of the first things I tried. It does nothing...doesn't add any entries to the menu at all.
I'd already tried most of those modules you suggested (not the graphics ones, but certainly part_gpt along with fat and a bunch of others) but none of them helped. I hadn't tried the preload line in /etc/default/grub so gave that a try (not that I can see how that could be the problem, when it's launching the Windows Boot Manager so can presumably see the (hd0,1) partition in order to get to that stage?), but nothing.
The vbe, vga and I think the ieee1275_fb modules reported that they were missing. Then after a few seconds it launched the WBM and gave me the same old error message.
Maybe my GRUB is broken somehow...I've patched it to be quieter and messed with the stuff in /etc/grub.d quite a bit...never had problems before but never tried chainloading Windows off a single physical disk before either...I'll try a bog-standard default install and maybe os-prober will work. |
|
Back to top |
|
 |
alamahant Advocate

Joined: 23 Mar 2019 Posts: 3961
|
|
Back to top |
|
 |
Goverp Advocate


Joined: 07 Mar 2007 Posts: 2298
|
Posted: Sat May 22, 2021 10:40 am Post subject: |
|
|
psycho wrote: | ...
Here's my current grub.cfg entry: Code: | menuentry 'Windows' --class windows {
insmod chain
chainloader (hd0,1)/EFI/Microsoft/Boot/bootmgfw.efi
} |
|
That's similar to mine; that has some mucking about with find to set $root by UUID, and mine works. So a couple of possibilities: (a) your drives aren't where you think they are (has been known), or summat else!
Please could you post (a) your disk layout - say blkid output from linux, (b) efibootmgr output, so we can see what works from BIOS?
Mucking about with modules, grub-mkconfig, os-prober and chainloader +1 won't change anything. Chainloading on my box works with a line just like yours and no module probing; as you're getting Windows bootloader messages, chainloading is working; the issue is with what it thinks is its configuration.
I knew I'd had a similar problem when I swapped the rust for an SSD in my laptop. Here's the note I made when Windows broke. _________________ Greybeard |
|
Back to top |
|
 |
skiwarz Apprentice

Joined: 23 Feb 2014 Posts: 280
|
Posted: Sun May 23, 2021 3:56 am Post subject: |
|
|
Yes. os-prober requires this. Also, here's an excerpt from my grub.cfg where I load windows from a different disk.
Code: | menuentry 'Windows Boot Manager (on /dev/nvme0n1p2)' --class windows --class os $menuentry_id_option 'osprober-efi-D646-F1C7' {
insmod part_gpt
insmod fat
search --no-floppy --fs-uuid --set=root D646-F1C7
chainloader /efi/Microsoft/Boot/bootmgfw.efi
} |
|
|
Back to top |
|
 |
psycho Guru


Joined: 22 Jun 2007 Posts: 553 Location: New Zealand
|
Posted: Sun May 23, 2021 4:32 am Post subject: |
|
|
Thanks for the continued suggestions. I'm on the road with a different laptop for a couple of days but will post those details when I get home. Re GRUB_DISABLE_OS_PROBER="false", yes, I had that in /etc/default/grub (os-prober failed to run at all until I did that): it was enabled and ran "successfully" but didn't detect any OS (or at least didn't add any to grub.cfg).
Re the UUID-based set root thing, that's certainly one of the many things I tried based on advice online...Windows is actually on hd0,6 and my pointing grub to there explicitly with "set root" didn't help, and I read somewhere that it needed the UUID method so gave it a try with no success...but it's possible I tried it too early (before repairing stuff with Windows boot repair), or even fed it the wrong UUID or something...anyway I'll give it another go when I get back, then if that doesn't work I'll try a vanilla grub with default configs (in case the patched version in my local repo and/or my heavily edited configs have broken something), then if none of that works I'll post my blkid and efibootmgr output. |
|
Back to top |
|
 |
|