61

I recently got a computer from school. It came with Windows 8.1 installed. I then installed another copy of Windows 8.1 (so it would use the built-in Windows Pro license) and upgraded it to Windows 10. I then installed Ubuntu alongside both Windows 8 and 10.

Note that I made a separate 255MB ext2 partition for /boot.

Now, when I boot the computer, I first see a GRUB prompt (I already un-hid the grub prompt 'cuz I like it that way) with Windows 8 and Ubuntu options. However, there is no Windows 10 option. If I select Ubuntu, the computer boots into Ubuntu. However, if I select the Windows 8 option, I then get sent to the Windows bootloader, where it then gives me options to boot either Windows 8 or Windows 10. (However, by this point, the computer has already loaded the kernel and all. Apparently Microsoft misunderstood the concept of a bootloader and decided that that meant "boot practically the entire system before actually showing the bootloader". Typical Microsoft.)

How can I disable the Windows bootloader and add a Windows 10 option to GRUB?

EDIT: Someone has answered telling me to disable the Windows bootloader. However, I still do not know how to add Windows to the GRUB OS list. Can anyone help with this?

EDIT 2: After removing Windows 10 from the Windows bootloader with EasyBCD, it seemed that, after a few reboots, it would continually unhide itself and Windows 10 would reappear. However, I then later deleted Windows 10 from the list of OSes in msconfig, and it seems to have stayed deleted.

However, I STILL have not managed to get Windows 10 to appear in GRUB. It's as if GRUB simply doesn't detect it.

Also, I'll put this in the question so that people see it - I have tried using boot-repair, however, it has NOT helped any.

7
  • 1
    @daltonfury42 Stop believing if you don't listen or don't understand what the requirements of the OP are! Recommending a tool that mostly addresses common problems in typical legacy boot setups, for untypical UEFI installations with special requirements is misleading and counter productive.
    – LiveWireBT
    Nov 14, 2015 at 13:09
  • 3
    @LiveWireBT I am so sorry. I saw your answer. I've deleted my comment (and stopped believing :P). Thanks! Nov 14, 2015 at 15:18
  • 1
    I think I'm going to just delete the entire Windows 10 partition and move it to a VM, anyways. Nov 14, 2015 at 15:33
  • Honestly not sure why people are still upvoting this, as IMO it's not a great question. However, this year I solved this in another way - by converting from MBR to GPT and UEFI boot. Basically, I converted the partitioning scheme to GPT, resized the Windows partition, added an EFI System Partition and put rEFInd on it, and created a Windows BCD using a Windows install disk. Now the system boots using UEFI boot, making it easier to play with OSes. Contrary to what the internet says, it wasn't too hard to convert the Windows install from BIOS to UEFI, but it wasn't easy either. Nov 30, 2016 at 14:51
  • 1
    For anyone in the future who wants to do something like this and wants to stick with BIOS - I believe the answer lies in the Windows BCD. I believe that the Windows 10 install doesn't have a proper bootloader or BCD or something, and is not actually capable of booting independently. If done properly, I have a hunch that GRUB should start automatically finding the Windows 10 partition. Nov 30, 2016 at 15:08

9 Answers 9

44

Sometimes os-prober is wrong.

Look at the UUID of your Windows 10 partition, for exemple:

sudo blkid /dev/sda2

Then edit /etc/grub.d/40_custom, and at the end of the file add:

menuentry "Windows 10" --class windows --class os {
   insmod ntfs
   search --no-floppy --set=root --fs-uuid $your_uuid_here$
   ntldr /bootmgr
}

Don't forget to change the UUID.

And finally update your grub config file:

sudo update-grub

Source

7
  • 4
    worth to note that for windows 10, usually the first partition is NOT the Windows system one, (i.e sdb2 is correct and sdb1 is NOT) This is because of how the windows 10 is stored on the disk during install, and the system reserved partition or system repair is always first). Grub often fails to find the second partition if the first one on the disk already provides something bootable. the easiest way to find the correct UUID is finding the biggest partition via sudo fdisk -l and match it with the result of blkid. Apr 9, 2017 at 14:28
  • Do you keep the $ signs around UUID?
    – Klesun
    Jan 23, 2020 at 23:25
  • 1
    No $ is just a placeholder
    – noraj
    Jan 24, 2020 at 12:00
  • 6
    Not working. It says: "error: can't find command 'ntldr'".
    – Artem P
    Apr 3, 2020 at 19:48
  • 2
    @hlcs use 'chainloader /EFI/Microsoft/Boot/bootmgfw.efi' instead of 'ntldr /bootmgr'. This worked well for me.
    – LeWimbes
    Aug 11, 2020 at 21:29
41

This solution provides a proper entry in the grub2 menu and chainloads directly into Windows 10 without reference to the BIOS. It comes from this webpage so I claim no credit. It was such a relief to find a working solution.

Briefly, edit /etc/grub.d/40_custom and add:

menuentry 'Windows 10' {
    search --fs-uuid --no-floppy --set=root CC66-4B02
    chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
}

To find the UUID for the --set=root line (CC66-4B02 in the example) you use sudo fdisk -l to identify the EFI partition then sudo blkid /dev/sda1 (or whatever) to find the UUID of the EFI partition. Note it's not the Windows partition but the EFI one you need. Once you've saved the edit, run sudo update-grub to generate the /boot/grub/menu.cfg file and then restart to test.

10
  • I guess the sudo /dev/sda1 command should be sudo blkid /dev/sda1
    – makapuf
    Mar 25, 2018 at 21:18
  • @makapuf - you're absolutely right, thank you. Corrected. Mar 26, 2018 at 23:13
  • I have followed that exact tutorial, and I get "Error: Partition not found" when i try to boot the entry. Upon mounting the partition, it seems that "EFI/Microsoft/Boot/bootmgfw.efi" does not exist on that partition.
    – xeruf
    Jan 16, 2019 at 7:00
  • 1
    You need to create EFI by running bcdboot C:\Windows /s C: /f uefi on Windows. See more: askubuntu.com/a/447687/160368.
    – Artem P
    Apr 3, 2020 at 20:53
  • 1
    Finnally working for me, I have a little confused about the UUID of EFI partition and not Windows partition, thank you so much :). Oct 16, 2020 at 13:57
29

Use:

sudo update-grub
sudo grub-install /dev/[BOOT PARTITION eg. Sda6]

commands in terminal of Ubuntu, probably it will solve your problem.

By this command the system will automatically detect your Windows installations and add them to the GRUB list.

9
  • 8
    This didn't work unfortunately. It does not seem to detect the Windows 10 partition. Sep 12, 2015 at 23:53
  • 1
    Actually I have had same problem with my system(have windows 10 and ubuntu 14.04), And it was solved by this commands.
    – Neel Shah
    Sep 14, 2015 at 4:41
  • Which command solved it, the update-grub or grub-install? And do you have a separate /boot partition? The thing is I have a separate boot partition on I think it actually is sda6. Sep 14, 2015 at 7:10
  • 2
    Doing those two commands (obviously) didn't solve it. Sep 14, 2015 at 7:11
  • 8
    sudo update-grub did it.
    – thameera
    Nov 22, 2016 at 13:35
13

use this app EasyBCD for windows http://neosmart.net/EasyBCD/ download the free version and install it.

when you open it you will see an entry for windows 8 and one for windows 10.

delete the windows 8 entry and you'll be good to go.

Update after doing the steps above go back to Ubuntu,

open the terminal by pressing ctrl+alt+T

then copy past this commands to it one after another,

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install -y boot-repair

and by this you will install a tool called boot-repair.

open boot repair from dash and you'll get this window

enter image description here

choose the recommended repair and follow the steps.

Note you have to be connected to the Internet when using boot-repair.

17
  • 1
    @Hitechcomputergeek if you need more help, let me know I'll boot to windows and make you some screen-shots.
    – user433732
    Aug 15, 2015 at 22:32
  • Does that add Windows 10 to GRUB? (Let me guess: no) I want to be able to access all three OSes from GRUB, and that only solves part of the problem. Aug 15, 2015 at 23:35
  • I updated the question to ask how to add Windows 10 to the GRUB OS list. I upvoted your answer because it fixed part of the problem, but since I still need to add Windows 10 to GRUB, I'm not accepting the answer yet. Aug 16, 2015 at 1:08
  • 2
    Also, I noticed you say to open Boot Repair from the dash, but the line sudo apt-get install -y boot-repair && boot-repair would already have opened it. Aug 17, 2015 at 0:45
  • 1
    You can also use this tool in "test mode of ubuntu (live cd mode)" iso where you can install, run and use it after connecting to internet or wife. Mar 7, 2017 at 16:58
5

As far as I understood your question you have two different Windows installations on one or more harddrives and you don't want the Windows loader to get in the way or managing both Windows installations. I remember that it was possible on legacy setups to directly boot the Windows kernel from Grub (I may be wrong here) but I haven't been able to do this on UEFI setups. Having two independent Windows bootloader configurations that can be called from Grub independently should be very close to what you are looking for.

It came with Windows 8.1 installed.

I'm going to assume that this is a UEFI capable computer.

  1. Please check that the computer actually is UEFI capable (I will remove my answer if it is not) and familiarize yourself with the differences between BIOS and UEFI (different boot modes, efibootmgr, different partition tables, EFI system partition (ESP), EFI loaders…).
  2. Then check that all OSes are installed in UEFI mode and check that you have a GPT partition table. You can use Windows' dism to backup and restore partitions to a new partition table layout and use the command prompt from latest Windows installation media to reinstall the bootloader, more details on this in the next point.
    • Since you have been recommended to try various other tools that don't address your issue you have to revert these changes to a pristine condition, otherwise this will get more and more confusing. Sorry about that. :(
  3. You can use my answer from How to boot Windows 8 from a legacy MBR partition in UEFI mode via GRUB?
    • This answer does install an independent Windows boot loader configuration through bcdboot in a different location where Grub will call it. For convenience I have chosen the Windows root partition. You will need to do this for every Windows installation, so that every Windows installation has its own and will only boot itself (clean the individual Windows boot menus from other entries).
    • Remember that you need to create an individual entry for each Windows installation you want to boot in /etc/grub.d/40_custom and follow the instructions and explanations about UUIDs, partitions and partition tables.
    • Probably disable every semi-smart feature that detects different OSes like OS-prober in Grub (GRUB_DISABLE_OS_PROBER) or troubleshooting boot issues with Windows or boot-repair (or manually clean up after them).

N.B.: Your request was to be able to manage all OSes with Grub, however with UEFI, the traditional "dualboot" term becomes almost a misnomer. UEFI allows coexistence of several bootloaders on the ESP and you can choose which one to boot (if they have been registered in the UEFI firmware and the manufacturers firmware doesn't do out of spec patronizing like only booting Windows). The sad thing here is that only very few people can think about installing more than one (independent) version of Windows, Linux or one release of Ubuntu onto one computer (or a harddrive that is used with several computers and boots a different installation of the same OS release on each computer). Most of this is already possible, but mechanisms in Windows and Ubuntu (Fedora,…) plainly choose to overwrite what is in their namespace under the false assumption that there can only be one.

(I do boot Windows8/10, Ubuntu, Ubuntu LTS and Fedora on one computer and have tinkered a few times with UEFI booting under different requirements.)

7
  • 1
    I do not use Windows. But has anyone tried copying /EFI/Windows to /EFI/Windows10 and/or /EFI/Windows8 and edit each BCD to be only for that version? And then in UEFI create entires for each. If that works from UEFI then grub can chain to each directly.
    – oldfred
    Nov 14, 2015 at 15:05
  • @oldfred That's sort of what I wanted to point to in the lower section and there may be even a parameter for bcdboot to specify another target directory, but I'm not sure. Chainloading the other EFI binaries from only one ESP greatly simplifies 40_custom and make it less error-prone, you are right with that. I think was focused too much on multi-harddrive scenarios (in that case you should still be able tell bcdboot to boot Windows on hdd2 from ESP on hdd1, I think). m(
    – LiveWireBT
    Nov 14, 2015 at 15:24
  • The computer is UEFI capable, but I honestly have no idea wtf is up with the partitions right now. The school had a custom Windows 8 image installed, and although it was using UEFI and Secure Boot (I believe the BIOS is configured to allow both UEFI and legacy boot right now; I remember disabling Secure Boot), the hard disk itself is formatted using MBR. Here, have a screenshot: imgur.com/1vDS4jf (Yeah, I'm planning on resizing a bunch of the partitions soon.) Also, Ubuntu itself (from grepping dmesg) doesn't appear to have been started in EFI mode, but I don't know if GRUB itself can Nov 19, 2015 at 4:22
  • @Hitechcomputergeek The screenshot shows an msdos/MBR partition table with an extended partition and no EFI partition. As I said earlier you should have GPT and you can use dism for the Windows partitions.
    – LiveWireBT
    Nov 19, 2015 at 4:33
  • be started as UEFI, but then start other OSes as not-UEFI or something. UEFI is confusing. EDIT: GRUB is not being started as UEFI. I have no idea what happened with the original Windows. Actually, come to think of it, I guess it's possible it WASN'T UEFI in the first place. I assumed it was because it was basically impossible to get into the BIOS because of Windows 8's hibernation thing, unless you first booted it, then hit "Restart", THEN tried to get into the BIOS. I haven't needed to do that again at all since installing Ubuntu (and GRUB). Nov 19, 2015 at 4:40
2

You need to create a new EFI Partition for the later installed windows. Because the one first installed had its own EFI but the later one seeing another windows just added its own entry to the bootloader now creating its own EFI in /EFI/Microsoft/Boot/bootmgfw.efi so fire up CMD as admin on your Windows 10 and enter the following commands (From here on TenForums):

diskpart
list disk
select disk # Note: Select the disk where Win10 is installed
list partition
select partition # Note: Select the Win10 installation partition.
shrink desired=100
create partition efi size=100
format quick fs=fat32
assign letter=s
list partition
list volume Note: Note the volume letter where the Win10 is installed.
exit

bcdboot X:\windows /s S:
Note: Replace "X" with the volume letter of the Win10 partition.

BCDBoot copies the boot files from the Windows partition to the EFI System partition and creates the BCD store in the same partition.

Now just add an entry pointing to this partition like this in /etc/grub.d/40_custom or (any custom file in /etc/grub.d/):

insmod part_gpt
insmod ntfs
set root=hd1,gpt10
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
2
  • Great answer! Last part with grub.d modification is not succesedded for me but after diskpart manipulations it is enough to write sudo os-prober and sudo update-grub Nov 15, 2020 at 19:21
  • Thanks! BTW Not sure why the grub.d part did'nt work out for you.
    – Ahmed
    Dec 6, 2020 at 10:09
2

Just login to your Ubuntu OS, open a terminal, and type in the following:

sudo update-grub

After this, reboot your system.

1

After looking for a solution for a while, and also being lazy for not trying to spend another hour finding out what and where should I edit and update (as it was futile) I eventually installed Grub Customizer. Works wonders!

1

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!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .