Modern EFI-based computers are much more flexible about boot options than were older BIOS-based computers. Under BIOS, you could select a default boot disk, or sometimes a non-disk device (like a network boot option), but that was about it. Under EFI/UEFI, boot loaders are programs stored in files on a disk, so one disk can contain many boot loaders, and you can set an order in which they're tried. Although most EFIs offer options to "boot a disk," that refers either to old BIOS-style booting (using something called the Compatibility Support Module, or CSM, which most likely isn't in play in your case); or booting using a "fallback" filename (EFI\BOOT\bootx64.efi
on x86-64 systems). The question reveals BIOS-style thinking about the boot process, but that can lead one badly astray when dealing with EFI-mode booting.
In a properly-configured computer that dual boots Windows and Ubuntu, there are likely to be at least two boot entries, one for each OS, and likely other system-specific boot options for fallback boot loaders, built-in tools, etc. You can see the boot options in Linux with the efibootmgr
tool, thus:
$ sudo efibootmgr
BootCurrent: 0000
Timeout: 1 seconds
BootOrder: 0000,0009,0006,0007,0008,0001,0002,0003
Boot0000* ubuntu
Boot0001* UEFI:CD/DVD Drive
Boot0002* UEFI:Removable Device
Boot0003* UEFI:Network Device
Boot0006* UEFI OS
Boot0007* Hard Drive
Boot0008* CD/DVD Drive
Boot0009* Windows Boot Manager
In this example, Boot0000
(aka ubuntu
) is first in the boot order and Boot0009
(aka Windows Boot Manager
) is second in the boot order (although it's at the bottom of the list of boot entries). You can see more details by adding -v
to the efibootmgr
command, but the extra information takes some knowledge to parse.
Most OSes, on installation, set their own boot loaders to be the default. This fact has implications because some OSes' boot loaders do a better job of detecting other OSes' existence than others. The easiest way to dual-boot Ubuntu and Windows is to install Windows first and then Ubuntu; Ubuntu's GRUB 2 setup scripts will normally detect Windows and add it to the GRUB 2 boot menu. If this doesn't work or if you installed in the other order, there are a number of steps you can take to fix things, but I can't be certain which step(s) will do the trick for you. Options include:
- Install my rEFInd boot manager, which scans for other OSes' boot loaders on every boot. You can install it in Ubuntu by typing
sudo apt install refind
.
- If
efibootmgr
shows that Windows is first in the boot order, you can change the boot order with the -o
option to efibootmgr
, as in sudo efibootmgr -o 0,9,6,7,8,1,2,3
in the above example (if Windows were first there). Note that the exact numbers you type will be extremely system-specific! Also, you probably only need the first number or two; the others exist in case the first one doesn't work.
- If you installed Ubuntu first and then Windows, then resetting the boot order with
efibootmgr
may be necessary, but won't be sufficient; you'll need to add Windows to the GRUB 2 configuration, too. This can normally be done with sudo update-grub
. If this doesn't work, then you're into advanced GRUB configuration, which is a pain. Installing rEFInd is likely to be easier, but I'm biased. (I maintain rEFInd.)
- If adjusting the boot order in
efibootmgr
doesn't have a permanent effect, then you're probably looking at a boot coup, which can be tricky to fix, as described on the linked page. Identifying the cause of the boot coup is important -- is it Windows resetting itself as the default on every boot? Is your NVRAM flaky? Is GRUB failing and exiting, leading to the EFI booting Windows instead? Is the UEFI firmware buggy? The best solution is different for each cause.