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.

singrium
  • 6,880
Hitechcomputergeek
  • 1,163
  • 2
  • 11
  • 18
  • 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 '15 at 13:09
  • 3
    @LiveWireBT I am so sorry. I saw your answer. I've deleted my comment (and stopped believing :P). Thanks! – daltonfury42 Nov 14 '15 at 15:18
  • 1
    I think I'm going to just delete the entire Windows 10 partition and move it to a VM, anyways. – Hitechcomputergeek Nov 14 '15 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. – Hitechcomputergeek Nov 30 '16 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. – Hitechcomputergeek Nov 30 '16 at 15:08
  • `Note that I made a separate 255MB ext2 partition for /boot. --

    Use ESP for/boot` in UEFI installations. It will make your life easier

    – Erkin Alp Güney May 15 '17 at 13:03
  • @ErkinAlpGüney At the time I wrote this question, the system was partitioned using MBR. – Hitechcomputergeek May 15 '17 at 20:57

9 Answers9

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

Zanna
  • 70,465
noraj
  • 801
  • 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. – Jan Myszkier Apr 09 '17 at 14:28
  • Do you keep the $ signs around UUID? – Klesun Jan 23 '20 at 23:25
  • 1
    No $ is just a placeholder – noraj Jan 24 '20 at 12:00
  • 6
    Not working. It says: "error: can't find command 'ntldr'". – Artem P Apr 03 '20 at 19:48
  • Same error as @hlcs here – Soutzikevich Jun 29 '20 at 19:26
  • 2
    @hlcs use 'chainloader /EFI/Microsoft/Boot/bootmgfw.efi' instead of 'ntldr /bootmgr'. This worked well for me. – LeWimbes Aug 11 '20 at 21:29
  • os-prober is pretty accurate (also detects Windows 10 installation on a completely separate drive). You just need to read it properly. Once you get the Wind10 destination (e.g. /dev/nvme1n1p3@/EFI/Microsoft/Boot/bootmgfw.efi) use blkid for the device (e.g. /dev/nvme1n1p3) to get the UUID. After that use chainloader parameter as @LeWimbes suggested with a slight modification namely chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi. – rbaleksandar Sep 14 '22 at 05:47
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.

fuenfundachtzig
  • 356
  • 3
  • 13
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.

Zanna
  • 70,465
Neel Shah
  • 428
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.

  • 1
    @Hitechcomputergeek if you need more help, let me know I'll boot to windows and make you some screen-shots. –  Aug 15 '15 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. – Hitechcomputergeek Aug 15 '15 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. – Hitechcomputergeek Aug 16 '15 at 01:08
  • @Hitechcomputergeek I updated the answer try it now. –  Aug 16 '15 at 08:43
  • I'll try later when I have more time, but please note that I've tried sudo update-grub multiple times; it doesn't seem to detect my Windows 10 partition. Also, I've set the boot flag on all three bootable partitions in gparted (before none had it), and sudo update-grub still doesn't find the Windows 10 partition. – Hitechcomputergeek Aug 16 '15 at 14:24
  • From what I see. Grub does detect your windows10. But still call it windows8. As grub is still not updated for windows 10. You still have the windows8 option in grub but boots to windows 10 after the easyBCD configuration. Right? –  Aug 16 '15 at 17:35
  • I haven't actually removed Windows 10 in EasyBCD yet as I don't want to lose access to Windows 10, but I believe that GRUB is booting into the Windows 8 partition, but that the Windows bootloader on the partition sees Windows 10, so instead of booting it first asks me if I want to boot into Windows 10 instead. – Hitechcomputergeek Aug 16 '15 at 23:45
  • 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. – Hitechcomputergeek Aug 17 '15 at 00:45
  • So I just tried boot-repair (from a flash drive, as it complained when I tried to run it from my Ubuntu install) and now the ONLY option in grub is Ubuntu. Even memtest86+ is mysteriously absent from the list. Geez, thanks! – Hitechcomputergeek Aug 17 '15 at 21:40
  • Also, please try to help me as fast as you can, as school starts Wednesday and I need to be able to boot into the Windows 8 by then. – Hitechcomputergeek Aug 17 '15 at 21:43
  • Nevermind about the last comment, I restored my backed-up /etc/default/grub, ran sudo update-grub, and now I can boot into Windows 8 again. However, memtest86+ is still absent from the boot list. I'd like to get that back. Also, I saved the log file from grub-customizer to the other partition on my live USB, so if you'd like me to post that I can. – Hitechcomputergeek Aug 17 '15 at 21:50
  • @Hitechcomputergeek you didn't have to restore your backup, all you had to was to run boot repair from Ubuntu that you already have. I have no idea how to restore memtest86+. –  Aug 17 '15 at 22:29
  • Yeah, but I did it anyways as I had already had the menu unhidden and the timeout set to 2 seconds like I prefer it to be. Also, I can try Googling it to figure how to get back MT86+. – Hitechcomputergeek Aug 18 '15 at 14:01
  • Well I got back Memtest86+. The original problem is still not solved. However, when I run EasyBCD and try to get rid of the Windows boot menu by deleting it, it seems to keep coming back after a boot or two. I've also tried setting it to skip the menu, which didn't work either. (I still need to play with it more though.) – Hitechcomputergeek Sep 12 '15 at 23:57
  • I used this boot repair app many times it is awesome solution for repairing grub. especially in case of multiboot system. It needs active internet connection . In image one can see clearly it solves frequent problems. So after manual change this software will be not able to detect your manually applied modifications. It is only for frequent problems which automatically occur. It automatically scans all bootable drives and provides solution accordingly – Alamjit Singh Mar 07 '17 at 16:57
  • 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. – Alamjit Singh Mar 07 '17 at 16:58
  • dont use that crap, easyBCD works with win7 only – Egon Stetmann. Nov 17 '17 at 01:45
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.)

LiveWireBT
  • 28,763
  • 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 '15 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 '15 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: http://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 – Hitechcomputergeek Nov 19 '15 at 04: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 '15 at 04: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). – Hitechcomputergeek Nov 19 '15 at 04:40
  • +LiveWireBT Darnit, you were too fast; I "edited" my comment by copying it, deleting it, and adding a bunch of stuff that I was one minute too slow on editing into it. Anyways, I've booted several school computers to Ubuntu over the years (although this is the first year that I actually was given one(not even technically my own - they take them back over the summer and reimage them - but whatever)), but I haven't extensively played with any before now. I've seen ones last year (also Windows 8) with and without the GPT partition (seemingly randomly), – Hitechcomputergeek Nov 19 '15 at 04:49
  • and I guess I assumed that this year they were all using UEFI because of the thing with the reboot, and the fact that the ThinkPad logo looks different. (This is the first year that they've been using this particular model; that's probably why.) – Hitechcomputergeek Nov 19 '15 at 04:51
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
Ahmed
  • 21
  • 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 – Sergey Orlov Nov 15 '20 at 19:21
  • Thanks! BTW Not sure why the grub.d part did'nt work out for you. – Ahmed Dec 06 '20 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.

Nidhan
  • 21
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!