If one has an EFI machine with Grub2Win on it and needs to use a Windows 10 Recovery USB drive they can change the EFI boot order in Grub2Win such that the EFI flash drive is before the Grub2Win option. Grub2Win will display a msg implying the EFI config sequence is in error. Disregard the error and click on Grub2Win's OK box then reboot. The Recovery USB drive will then boot.
A Grub2Win menu option to boot the Recovery USB drive directly might be worth investigating.
And yes, one can boot to a machine's boot option menu and choose the USB drive that way.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I manually added this to the grub.cfg menu but Grub2Win threw up when it edited it. LOL
Menu Entry 2 Windows Recovery
menuentry 'Windows Recovery' --class other --class icon-windows {
set reviewpause=15
if [ $grub2win_bootmode = EFI ]; then
set efibootmgr=/bootmgr.efi
getbootpartition file $efibootmgr
if [ $reviewpause -gt 0 ] ; then
echo Grub is now booting Windows EFI Recovery
echo Boot disk address is $root
echo The boot mode is Windows EFI
sleep -v -i $reviewpause
fi
chainloader $efibootmgr
else
echo
echo No Recovery drive found at ($root)
echo
sleep -v -i $reviewpause
fi
savelast 2 'Windows Recovery'
}
became
Menu Entry 2 Windows Recovery
menuentry 'Windows Recovery' --class other --class icon-windows {
The issue here is that Grub2Win is not designed for the
C:\grub2\grub.cfg file to be directly edited (except for the user section).
I designed it in this way to keep syntax errors and unbootable systems
to a minimum. You know all about that (:
A less risky way to accomplish your goal is to enter custom code through
the GUI, instead of editing the grub.cfg file.
I entered your custom code through the GUI and it worked properly. The
program generated the following menuntry which continues to be properly
generated each time I run Grub2Win:
Menu Entry 9 Windows Recovery For Ed - Custom Code
menuentry 'Windows Recovery For Ed - Custom Code' --class
other --class icon-windows --class custom_009 {
set reviewpause=2
start-custom-code
if [ $grub2win_bootmode = EFI ]; then
set efibootmgr=/bootmgf.efi
getbootpartition file $efibootmgr
if [ $reviewpause -gt 0 ] ; then
echo Grub is now booting Windows EFI Recovery
echo Boot disk address is $root
echo The boot mode is Windows EFI
sleep -v -i $reviewpause
fi
chainloader $efibootmgr
else
echo
echo No Recovery drive found at($root)
echo
sleep -v -i $reviewpause
fi
end-custom-code
sleep -i -v $reviewpause
savelast 9 'Windows Recovery For Ed - Custom Code'
}
Dave
I manually added this to the grub.cfg menu but Grub2Win threw up when it
edited it. LOL
Menu Entry 2 Windows Recovery
menuentry 'Windows Recovery' --class other --class icon-windows {
set reviewpause=15
if [ $grub2win_bootmode = EFI ]; then
set efibootmgr=/bootmgf.efi
getbootpartition file $efibootmgr
if [ $reviewpause -gt 0 ] ; then
echo Grub is now booting Windows EFI Recovery
echo Boot disk address is $root
echo The boot mode is Windows EFI
sleep -v -i $reviewpause
fi
chainloader $efibootmgr
else
echo
echo No Recovery drive found at($root)
echo
sleep -v -i $reviewpause
fi
savelast 2 'Windows Recovery'
}
became
Menu Entry 2 Windows Recovery
menuentry 'Windows Recovery' --class other --class icon-windows {
set reviewpause=15
start-custom-code
end-custom-code
I agree with all your points. But the code you posted doesn't boot the recovery drive. See the code I posted below.
My code and my manual changing of the cfg file are stickly me hacking and attempts to prove the idea works. And it does at this point, so maybe you might want to consider adding it as another menu type to Grub2Win, with better code. lol
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
if [ $grub2win_bootmode = EFI ]; then
set efibootmgr=/bootmgr.efi
getbootpartition file $efibootmgr
if [ search.file $efibootmgr ]; then
--set=root
set efibootmgr=/efi/boot/bootx64.efi
if [ $reviewpause -gt 0 ] ; then
echo Grub is now booting Windows EFI Recovery
echo Boot disk address is $root
echo The boot mode is Windows EFI
sleep -v -i $reviewpause
fi
fi
chainloader $efibootmgr
else
echo
echo No Recovery drive found.
echo
sleep -v -i $reviewpause
fi
This code was entered properly using Grub2Win's Editing Menu's custom code (Other) option and tested both with and without a Recovery drive plugged in.
if [ $grub2win_bootmode = EFI ]; then
set USB_drv=/bootmgr.efi
set USB_efibootmgr=/efi/boot/bootx64.efi
getbootpartition file $USB_drv
if [ $reviewpause -gt 0 ] ; then
echo Grub will now boot Windows USB Recovery drive
echo Boot disk address is $root
echo Boot mode is Windows EFI
echo
echo Booting will be slow. Be patient.
sleep -v -i $reviewpause
set reviewpause=0
fi
chainloader $USB_efibootmgr
fi
The only two lines that might change for a user are the two that set the USB variables.
Probably not a popular item but I wanted to share my efforts for the one or two of you that may want to use this. :D
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Windows doesn't boot but Fedora and Ubuntu boot just fine with grub2win?
I discovered locating a file named bootmgfw.efi is the key to determining which EFI partition has a bootable windows partition. My machine has 3 drives with identical EFI partitions. 2 are external USB drives one with Fedora and one with Ubuntu. The one true EFI partition is on the first internal SATA drive and that drive also has the bootable windows partition. I renamed the file in both the 2 wrong EFI partitions ,
rename /EFI/Microsoft/Boot/bootmgfw.efi to /EFI/Microsoft/Boot/bootmgfw.efi.hide
Now grub2win does not "see" these wrong files and selects the one true EFI partition to invoke chainloader with success.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yes windows boots now when I hide the inappropriate /efi/Microsoft/Boot/bootmgfw.efi files.
I know Windows only expects one EFI partition. I think they expectthe UEFI bios to sort out which one is 'the one true' EFI partition.I was lazy... just replicating the same data in all three EFI partitionswith UEFI boot directories for all 3 OSes.Fedora and Ubuntu are happy to boot across different disks from EFI paritionto root partition. Windows is more restricted.
FYI Grub2Win 8.1.5
If one has an EFI machine with Grub2Win on it and needs to use a Windows 10 Recovery USB drive they can change the EFI boot order in Grub2Win such that the EFI flash drive is before the Grub2Win option. Grub2Win will display a msg implying the EFI config sequence is in error. Disregard the error and click on Grub2Win's OK box then reboot. The Recovery USB drive will then boot.
A Grub2Win menu option to boot the Recovery USB drive directly might be worth investigating.
And yes, one can boot to a machine's boot option menu and choose the USB drive that way.
I manually added this to the grub.cfg menu but Grub2Win threw up when it edited it. LOL
Menu Entry 2 Windows Recovery
menuentry 'Windows Recovery' --class other --class icon-windows {
set reviewpause=15
if [ $grub2win_bootmode = EFI ]; then
set efibootmgr=/bootmgr.efi
getbootpartition file $efibootmgr
if [ $reviewpause -gt 0 ] ; then
echo Grub is now booting Windows EFI Recovery
echo Boot disk address is $root
echo The boot mode is Windows EFI
sleep -v -i $reviewpause
fi
chainloader $efibootmgr
else
echo
echo No Recovery drive found at ($root)
echo
sleep -v -i $reviewpause
fi
savelast 2 'Windows Recovery'
}
became
Menu Entry 2 Windows Recovery
menuentry 'Windows Recovery' --class other --class icon-windows {
set reviewpause=15
start-custom-code
end-custom-code
sleep -i -v $reviewpause
savelast 2 'Windows Recovery'
}
:-(
Last edit: Ed P 2017-02-14
Hi again Ed,
The issue here is that Grub2Win is not designed for the
C:\grub2\grub.cfg file to be directly edited (except for the user section).
I designed it in this way to keep syntax errors and unbootable systems
to a minimum. You know all about that (:
A less risky way to accomplish your goal is to enter custom code through
the GUI, instead of editing the grub.cfg file.
I entered your custom code through the GUI and it worked properly. The
program generated the following menuntry which continues to be properly
generated each time I run Grub2Win:
Menu Entry 9 Windows Recovery For Ed - Custom Code
menuentry 'Windows Recovery For Ed - Custom Code' --class
other --class icon-windows --class custom_009 {
set reviewpause=2
start-custom-code
if [ $grub2win_bootmode = EFI ]; then
set efibootmgr=/bootmgf.efi
getbootpartition file $efibootmgr
if [ $reviewpause -gt 0 ] ; then
echo Grub is now booting Windows EFI Recovery
echo Boot disk address is $root
echo The boot mode is Windows EFI
sleep -v -i $reviewpause
fi
chainloader $efibootmgr
else
echo
echo No Recovery drive found at($root)
echo
sleep -v -i $reviewpause
fi
end-custom-code
sleep -i -v $reviewpause
savelast 9 'Windows Recovery For Ed - Custom Code'
}
Dave
I manually added this to the grub.cfg menu but Grub2Win threw up when it
edited it. LOL
Menu Entry 2 Windows Recovery
menuentry 'Windows Recovery' --class other --class icon-windows {
set reviewpause=15
if [ $grub2win_bootmode = EFI ]; then
set efibootmgr=/bootmgf.efi
getbootpartition file $efibootmgr
if [ $reviewpause -gt 0 ] ; then
echo Grub is now booting Windows EFI Recovery
echo Boot disk address is $root
echo The boot mode is Windows EFI
sleep -v -i $reviewpause
fi
chainloader $efibootmgr
else
echo
echo No Recovery drive found at($root)
echo
sleep -v -i $reviewpause
fi
savelast 2 'Windows Recovery'
}
became
Menu Entry 2 Windows Recovery
menuentry 'Windows Recovery' --class other --class icon-windows {
set reviewpause=15
start-custom-code
end-custom-code
sleep -i -v $reviewpause
savelast 2 'Windows Recovery'
}
:-(
Hi Dave,
It looks like we crossposted.
I agree with all your points. But the code you posted doesn't boot the recovery drive. See the code I posted below.
My code and my manual changing of the cfg file are stickly me hacking and attempts to prove the idea works. And it does at this point, so maybe you might want to consider adding it as another menu type to Grub2Win, with better code. lol
It's not pretty, I'm sure dpdrummer can do a better job, but this works. :-)
Menu Entry 2 Windows Recovery Drive
menuentry 'Windows Recovery Drive' --class other --class icon-xtra-04 --class custom_002 {
set reviewpause=15
start-custom-code
if [ $grub2win_bootmode = EFI ]; then
set efibootmgr=/bootmgr.efi
getbootpartition file $efibootmgr
if [ search.file $efibootmgr ]; then
--set=root
set efibootmgr=/efi/boot/bootx64.efi
if [ $reviewpause -gt 0 ] ; then
echo Grub is now booting Windows EFI Recovery
echo Boot disk address is $root
echo The boot mode is Windows EFI
sleep -v -i $reviewpause
fi
fi
chainloader $efibootmgr
else
echo
echo No Recovery drive found.
echo
sleep -v -i $reviewpause
fi
savelast 2 'Windows Recovery'
}
end-custom-code
sleep -i -v $reviewpause
savelast 2 'Windows Recovery'
}
Ok, my final menu for this function.
This code was entered properly using Grub2Win's Editing Menu's custom code (Other) option and tested both with and without a Recovery drive plugged in.
if [ $grub2win_bootmode = EFI ]; then
set USB_drv=/bootmgr.efi
set USB_efibootmgr=/efi/boot/bootx64.efi
getbootpartition file $USB_drv
if [ $reviewpause -gt 0 ] ; then
echo Grub will now boot Windows USB Recovery drive
echo Boot disk address is $root
echo Boot mode is Windows EFI
echo
echo Booting will be slow. Be patient.
sleep -v -i $reviewpause
set reviewpause=0
fi
chainloader $USB_efibootmgr
fi
The only two lines that might change for a user are the two that set the USB variables.
Probably not a popular item but I wanted to share my efforts for the one or two of you that may want to use this. :D
Windows doesn't boot but Fedora and Ubuntu boot just fine with grub2win?
I discovered locating a file named bootmgfw.efi is the key to determining which EFI partition has a bootable windows partition. My machine has 3 drives with identical EFI partitions. 2 are external USB drives one with Fedora and one with Ubuntu. The one true EFI partition is on the first internal SATA drive and that drive also has the bootable windows partition. I renamed the file in both the 2 wrong EFI partitions ,
rename /EFI/Microsoft/Boot/bootmgfw.efi to /EFI/Microsoft/Boot/bootmgfw.efi.hide
Now grub2win does not "see" these wrong files and selects the one true EFI partition to invoke chainloader with success.
Hi Niels,
You are correct. Grub2Win searches for file /efi/Microsoft/Boot/bootmgfw.efi
This is the Microsoft Windows bootmanager for EFI systems.
Grub2Win sets root to the drive where the file is found and then chainloads it.
Having three EFI partitions may cause confusion, both for you and for Windows.
Not recommended. Windows only expects a single EFI partition.
So does Windows boot for you now?
Please let me know.
Thanks,
Dave
yes windows boots now when I hide the inappropriate /efi/Microsoft/Boot/bootmgfw.efi files.
I know Windows only expects one EFI partition. I think they expectthe UEFI bios to sort out which one is 'the one true' EFI partition.I was lazy... just replicating the same data in all three EFI partitionswith UEFI boot directories for all 3 OSes.Fedora and Ubuntu are happy to boot across different disks from EFI paritionto root partition. Windows is more restricted.
Hi Niels,
You are correct. Grub2Win searches for file /efi/Microsoft/Boot/bootmgfw.efi
This is the Microsoft Windows bootmanager for EFI systems.
Grub2Win sets root to the drive where the file is found and then chainloads it.
Having three EFI partitions may cause confusion, both for you and for Windows.
Not recommended. Windows only expects a single EFI partition.
So does Windows boot for you now?
Please let me know.
Thanks,
Dave
EFI machine, EFI Grub2Win, EFI Recovery USB drive
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/grub2win/discussion/general/
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/
I'm reasonably sure renaming the EFI folder on the USB drives would work also.