36

The TL;DR, added in the edit:

The question is:

How can I make the BIOS prefer GRUB over Windows Boot Manager on the same UEFI boot partition?

The problem is not with Grub; Grub does the right thing when the BIOS starts it. The problem is not with "the disk isn't bootable," because both the Windows UEFI bootstrap and the Grub UEFI bootstrap are bootable. The problem is which UEFI bootstrap the BIOS chooses to boot from.

I'm setting up a new computer, and want it to by default boot into Ubuntu, but have the option to select Windows on boot. This is especially important if power goes out and comes back; I won't even be in the house.

I started out by installing Ubuntu 17.04 on my internal NVMe disk, partitioned with GPT to use half the disk, and a separate UEFI boot partition. GRUB boots that just fine, and I see the GRUB boot menu on start-up where I can select whatever items GRUB knows about.

Then I installed Windows 10 Pro from a recently downloaded ISO. It installed Windows Boot Manager onto the same UEFI partition, and left the Ubuntu intact (great!) and that boots fine into Windows 10.

However, it did "something" that makes the UEFI firmware immediately select the Windows Boot Manager rather than GRUB on power-up. The only way to boot Linux now is to use the BIOS boot manager (F11 on my BIOS) and select the GRUB boot loader manually. The UEFI BIOS knows that there are multiple bootable installs on the UEFI partition, because I can choose between them in the boot manager. However, when I'm in the setup menu in the UEFI BIOS, it just lets me choose "UEFI boot my internal drive" in the boot priority selection -- it doesn't let me choose which particular boot loader on that partition to use. And, by default, it chooses Windows, not GRUB.

The internets (and this site) suggests that the old way to fix this is to run update-grub (so GRUB recognizes Windows) and then grub-install (to put GRUB back on the device.) I have done this, but unfortunately, it still has the behavior as described above, where the BIOS by default chooses Windows Boot Manager. (update-grub does find the Windows Boot Manager install, and adds that to the menu, and that menu item works when I manually choose the GRUB partition in the UEFI boot manager.)

What can I do to make GRUB the "default" boot on my UEFI boot partition?

Using a MSI X399 Carbon motherboard.

Second edit: Because the correct answer ends up being mentioned in a comment to a response, I'll repeat it here:

"BCDEDIT" in an admin shell on Windows is the working solution. The others don't work.
2
  • You just have to install Windows then Linux. Not the other way around. I have the exact opposite problem. When power goes out then gets back, my computer goes into grub and boots into Linux, smh. One thing tho, is that I have each system on their own drive. On the boot order, I pick the drive with Linux and Grub in it.
    – dmb
    Feb 19, 2019 at 13:16
  • 1
    It's amazing how many people suggest things that are already suggested by other people, and I already said didn't work, either in my original post, or in the comments below. The correct solution was "BCDEDIT" in a Windows admin shell. None of the other suggestions solved it (and most of them, I had already tried, as per my question.)
    – Jon Watte
    Feb 21, 2019 at 1:51

8 Answers 8

36

There are quite a few different ways to do this, including:

  • The EFI setup utility -- Most EFIs provide setup utilities that you can access by hitting a special key at boot time (Esc, Del, or a function key, typically; but what key it is varies from one system to another). These often, but not always, provide a way to adjust the boot order. If your firmware provides such an option, you should be able to use it to move GRUB to the top position. (GRUB is likely to be called ubuntu, given that you installed it from that distribution.)
  • An EFI shell -- You can use the bcfg command in an EFI version 2 shell, as described on the Arch Linux wiki. If your system isn't already set up with an easy-to-access shell, this approach is likely to be harder to use than the others, but it is OS-agnostic.
  • EasyUEFI -- The third-party Windows EasyUEFI program is likely to be the easiest way to do what you want. You can click the ubuntu entry in EasyUEFI's list and move it to the top.
  • bcdedit -- The Windows bcdedit command can alter the NVRAM-based boot order. Specifically, opening an Administrator Command Prompt window and typing bcdedit /set "{bootmgr}" path \EFI\ubuntu\shimx64.efi (optionally followed by bcdedit /set "{bootmgr}" description "ubuntu" to keep the description sensible) should do the trick.
  • efibootmgr -- This Linux tool can adjust the boot order. Begin by typing sudo efibootmgr alone to see the options. Note the number (Boot####) associated with the ubuntu entry, and the current boot order (on the BootOrder line). You can then enter a new boot order with the ubuntu entry at the top by using the -o option. For instance, if the current boot order is 0000,0003,0007,0004 and ubuntu is 0007, you'd type sudo efibootmgr -o 0007,0000,0003,0004 to adjust the boot order.
  • refind-mkdefault -- This script comes with rEFInd, and it's a way to automate the preceding procedure. If you're not using rEFInd, you'd need to download the script here and make it executable (chmod a+x refind-mkdefault). You'd then run it as sudo ./refind-mkdefault -L ubuntu or sudo ./refind-mkdefault -L shimx64 to make GRUB the default boot entry.

There are potential problems and complications with any of these options. The most likely complicating factor is if there are old or alternative ubuntu boot entries. It's important that you move the correct one to the top position in the boot order; if you move the wrong one, you'll end up with either no change in behavior or something non-functional booting, which would make it harder to boot. If you use efibootmgr, the BootCurrent line may help you to tell which option you should set as the default.

There are other ways to do it that are overkill. Re-installing GRUB (via Boot Repair or grub-install) should do the trick, for instance. These approaches run the risk of damaging a known-working GRUB configuration, though.

Note also that some EFIs are buggy and there are other issues that can make it difficult to get GRUB to boot reliably. You may want to check out these questions and answers on AskUbuntu if you run into such problems:

3
  • 1
    As I described in the question, the EFI setup utility wouldn't let me pick ubuntu as a default, although it let me do that in manual boot menu. It would just let me pick the drive, and then starts Windows from that. efibootmgr attempted to change the boot order, but BIOS didn't pay attention on reboot. EasyBCD didn't work -- it didn't let me add more menu items. However, "BCDEDIT" in an admin shell actually did work, so thanks for that option!
    – Jon Watte
    Sep 8, 2017 at 3:29
  • Note that EasyBCD and EasyUEFI are two different programs from the same vendor. Sadly it seems that the free version of EasyUEFI is no longer available - only trial versions are offered. However, BOOTICE is another free program that can edit the UEFI boot settings: original Chinese site, English-language site with description and screenshots.
    – telcoM
    Oct 14, 2018 at 15:40
  • Using sudo efibootmgr -n 0002 is much better than modify current SO order. It changes BootNext: 0001 and leave BootCurrent: 0002 for next time, leaving your current GRUB entries untouched. Just add a bash with chmod +x and wrapping that command with along the reboot one.
    – m3nda
    Jul 9, 2019 at 14:55
4

I've been having this exact problem the past few weeks. I figured it out using these options. Before doing any of these things I recommend you to go into your BIOS/UEFI and check the boot order and make sure where grub is installed is first in order.

So how I see it is you have two options.

Option 1

What I would recommend to you is install Windows 10 first. Then install ubuntu. But I know it is kinda taboo to just say "reinstall your software" so I'll offer an alternative too.

Option 2

With your current setup I would recommend you to boot into a Live Ubuntu CD/flash drive and install and run boot-repair. Click the "Recommended Repair" option and follow the instructions given. Go through it carefully and read all the commands before executing. This will override the current grub installation with a new one which should hopefully fix it.

3
  • Thansk for the suggestions, but I had already tried those. The first time I installed things, I went Windows 10 first, then Ubuntu 17.04, then Boot Repair. It still defaulted to Windows, and then I wiped and re-installed with Ubuntu first, which brings me to where I am now.
    – Jon Watte
    Sep 7, 2017 at 1:13
  • I assume you've tried to adjust the boot order in your UEFI, right?
    – chisp2000
    Sep 7, 2017 at 6:24
  • Yes, as I say: "when I'm in the setup menu in the UEFI BIOS, it just lets me choose "UEFI boot my internal drive" in the boot priority selection -- it doesn't let me choose which particular boot loader on that partition to use"
    – Jon Watte
    Sep 8, 2017 at 3:12
2

I see several solutions:

  1. Edit your UEFI to adjust the default. On linux you can use efibootmgr. On Windows I'm not sure but I think you can boot into a recovery option that lets you configure the UEFI. Or you might prefer to install something like rEFInd.
  2. Change the folder name on the EFI partition. I think it prefers, or falls back to, a folder called boot.
  3. Just use the Windows boot loader, I think it can be configured to boot other OSes.
3
  • 1
    I could edit boot order using efibootmgr, but the BIOS ignores it and starts Windows anyway. Changing the boot folder name (or even copying grub into "boot") doesn't work until I remove the Microsoft one. The Windows boot loader doesn't boot non-Windows OS-es (at least not unsigned ones.)
    – Jon Watte
    Sep 8, 2017 at 3:20
  • @JonWatte Maybe the uefi bootloader is different, I remember booting ubuntu from windows 7 bootloader on a 32-bit bios machine. Maybe it can still chainload grub2? Since efibootmgr doesn't work, I know I won't be buying MSI.
    – jiggunjer
    Sep 8, 2017 at 4:12
  • Yeah, this MSI motherboard has some other problems too and is going back to Amazon in exchange for a Gigabyte.
    – Jon Watte
    Sep 8, 2017 at 4:21
2

I just had my mother board replaced in my laptop and grub disappeared completely.

I know this is marked as fixed but I thought that it may be useful for you.

To make grub appear as a boot option. I needed to add a EFI to bios.

I went to the "boot list option" in my bios. Clicked on "Add Boot Option" (I am aware that this is bios specific). This gave me an option for file name, which in my case was \EFI\ubuntu\grubx64.efi and gave it a name grub

I then moved the grub entry to the top of the boot sequence, and now it shows as the default entry.

I.e. what I'm saying is you may just need to locate the correct EFI file and move it to the top of your boot sequence / order.

1
1

None of above options worked for me with old HP 655 laptop. I found out solution is to set windows boot manager inactive:

sudo -s
efibootmgr
efibootmgr -b 4 --inactive

Replace 4 with your number of windows boot manager. Run efibootmgr again and you should see star disappear to mark inactivity.

After my computer boots to grup boot menu and windows can be still chosen from that.

1
  1. Move EFI/Microsoft to somewhere else.

  2. Reboot into grub linux. Since the Microsoft/ is gone, there is no way to boot into Windows.

  3. Move back EFI/Microsoft.

  4. update-grub Because this time it's booted from EFI mode, update-grub will get a different result compared to the BIOS mode.

  5. grub-install --target=x86_64-efi

  6. At last, you can optionally choose a different boot timeout to 1 second by default. By running efibootmgr -t 100.

0

Found the easy answer I was looking for. I am using an HP laptop from 2016 with Insyde BIOS, trying to run Ubuntu 22.04. In BIOS set up (F2 or whatever you need at the start of boot to access the BIOS screens)

  1. go to System Configuration, Boot Options.
  2. Select >UFI Boot Manager,
  3. pick the boot system of your choice (F5=up F6=down),
  4. Hit F10 to confirm entry,
  5. Hit F10 again to exit and save.
  6. You're done.

This is not how I have seen it on other installs that worked right out of the box. Now the Grub menu loads first.

1
  • This answer didn't actually address the original problem at all. As you can see in the original question, that was already tried, and didn't work, because there was a single boot manager option for "boot UEFI drive" which then always picked the Windows boot out of all available boots on that drive.
    – Jon Watte
    Feb 7, 2023 at 2:05
-2

A possible solution would be manually editing the /etc/default/grub file.

sudo vim /etc/default/grub

The default entry is determined by the GRUB_DEFAULT= setting in /etc/default/grub. The first "menu entry" has a value of "0". If Ubuntu is the second entry in the boot screen then set GRUB_DEFAULT=1.

Afterward, you would need to run the command to update grub config: update-grub

Another option would be installation grub-customizer and use its GUI to configure boot priority.

3
  • 1
    The problem is not with Grub. As I said in the post, if I can make the BIOS choose the Grub UEFI boot option, then I get the Grub boot-up menu, which lets me choose Windows or Ubuntu. This is the menu I want by default. Unfortunately, the BIOS chooses Windows Boot Manager by default.
    – Jon Watte
    Sep 7, 2017 at 1:14
  • As I said, you can fix it in grub boot order by configuring Ubuntu as the first system to start. Use grub-customizer to do this using GUI. linuxandubuntu.com/home/… Sep 7, 2017 at 8:21
  • 1
    Again, Grub doesn't even get started by the BIOS. Grub boot order doesn't matter. GRUB_DEFAULT doesn't matter. That's not the problem here.
    – Jon Watte
    Sep 8, 2017 at 3:26

You must log in to answer this question.

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