Windows 10 will, for the most part, be added to grub boot menu by the os-prober automajically.
For my specific setup I wanted to completely hide grub menu and automatically boot windows unless a hotkey was pressed to boot Ubuntu. So in my specific case os-prober isn't an option because the most important step in hiding the grub menu, which most answers I found neglect to mention, is to set the disable os-prober flag or the menu WILL be shown until os-prober completes.
It took considerably longer than I had anticipated to get right because there are so many partial answers out there but most are version dependant and can lead you astray. I spent a lot of time trying write my own grub menu entry trying use grub commands that didn't exist like ntdlr. Another caveat is that the chainloader functions on my grub try to boot bios not efi and will not work.(Im sure I was doing something wrong?)
In the end the solution was actually simple as the scripts that make your /boot/grub/grub.cfg do most of the work for you in finding UUIDS for your boot partitions. So you can skip the fdisk and blkid steps most people mention.
So step 1 is to make sure /boot/grub/grub.cfg is current using update-grub to make .cfg file. In terminal
sudo update-grub
Step 2 is to add custom menu entries in /etc/grub.d/40_custom. Don't waste time trying to write your own simply open /boot/grub/grub.cfg search "menuentry" and copy the automatically generated entries.
The first in the list will be ubuntu mine looks like
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-9e66eed6-e672-49ff-a07c-afdc00809148' {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 9e66eed6-e672-49ff-a07c-afdc00809148
else
search --no-floppy --fs-uuid --set=root 9e66eed6-e672-49ff-a07c-afdc00809148
fi
linux /boot/vmlinuz-5.4.0-39-generic root=UUID=9e66eed6-e672-49ff-a07c-afdc00809148 ro quiet splash $vt_handoff
initrd /boot/initrd.img-5.4.0-39-generic
}
Windows will be similar. Copy both to /etc/grub.d/40_custom. The only change I made for Ubuntu is to add the --hotkey=key flag which will make grub boot the os associated with that hotkey.
menuentry 'Ubuntu2' --class ubuntu --class gnu-linux --class gnu --class os --hotkey=u $menuentry_id_option 'gnulinux-simple-9e66eed6-e672-49ff-a07c-afdc00809148' {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 9e66eed6-e672-49ff-a07c-afdc00809148
else
search --no-floppy --fs-uuid --set=root 9e66eed6-e672-49ff-a07c-afdc00809148
fi
linux /boot/vmlinuz-5.4.0-39-generic root=UUID=9e66eed6-e672-49ff-a07c-afdc00809148 ro quiet splash $vt_handoff
initrd /boot/initrd.img-5.4.0-39-generic
}
I use --hotkey=u here to set Ubuntu boot hotkey to u.
Then I tweaked the Windows entry, replacing $menuentry_id_option withe the grub --id flag.
menuentry "Windows 10" --class windows --class os --id windows-custom {
insmod part_gpt
insmod fat
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 0EAE-C882
else
search --no-floppy --fs-uuid --set=root 0EAE-C882
fi
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
I used --id windows-custom. Save chages to /etc/grub.d/40_custom.
Finally open /etc/default/grub and add
GRUB_DISABLE_OS_PROBER=true
change GRUB_DEFAULT=0
to GRUB_DEFAULT=windows-custom
and change GRUB_TIMEOUT=10
to your choice of timings I use 0.5 just to give myself a little extra time to hit u to boot Ubuntu after POST.
Hopefully this saves someone a bit of headache, cheers!
`Note that I made a separate 255MB ext2 partition for /boot. --
– Erkin Alp Güney May 15 '17 at 13:03Use ESP for
/boot` in UEFI installations. It will make your life easier