Does this answer work for UEFI computers?

30,715

Solution 1

If you have EFI, then there will be an EFI System Partition (ESP) on the disk. This partition has to be mounted on /boot/efi, so that GRUB can use it. The partition:

  • is formatted FAT32,
  • is usually small (100MB < size < 500MB)
  • will have the boot flag enabled
  • contains an EFI folder
  • could be labelled EFI by the OEM, but no guarantees

I don't have one on hand, but you can see examples of how such a partition will look:

So, the task here is, somewhere around steps 3 & 4:

  1. Find the ESP
  2. Mount it:

    sudo mount /dev/sdXY /mnt/boot/efi
    

Then you can proceed with your usual answer. I have done it myself. Consider it similar to mounting a /boot partition if you have one separate.

You can mount it anywhere you like. In that case, just specify the mount directory to GRUB while installing:

grub-install --efi-directory=/foo/bar /dev/sdX

Solution 2

In your original answer, you wrote:

When you install Windows, Windows assumes it is the only operating system (OS) on the machine, or at least it does not account for Linux. So it replaces GRUB with its own boot loader.

This isn't true under EFI. Well, Windows is still pretty rude, and could be said to assume it's the only OS, but it does not replace GRUB. Under EFI, multiple boot loader coexist on the EFI System Partition (ESP), and Windows does not delete or replace GRUB.

That said, the average user might not notice any difference in symptoms between a BIOS-mode and an EFI-mode installation of Windows after Ubuntu, because what Windows does in EFI mode is to set its own boot loader as the default. Thus, the computer ends up booting Windows instead of Ubuntu. This looks like the same problem as under BIOS, but it's not.

Something similar to your solution may work under EFI, but it's overkill, and therefore has the potential to create more problems than it solves. In outline, the simplest way to get GRUB back after installing Windows under EFI is:

  1. Boot to Windows.
  2. Download and install EasyUEFI.
  3. Using EasyUEFI, move the ubuntu entry to the top of the boot order list.
  4. Reboot. Ubuntu should boot, but there will be no Windows option.
  5. In Ubuntu, type sudo update-grub in a Terminal window.

At this point, Windows should show up as an option in the GRUB menu on the next reboot.

An alternative would use the built-in Windows program bcdedit instead of EasyUEFI, but EasyUEFI is, well, easier, despite being a third-party program that must be downloaded and installed.

Share:
30,715

Related videos on Youtube

Scott Severance
Author by

Scott Severance

My first Linux experience was in 1998 (via telnet into my university's server to read my email with PINE). I've run Linux on my own machines off and on since 1999 and exclusively since 2006. My first distro was Slackware, which I quickly broke. I then went back to Windows 95. After that, my friend helped me install Debian, which I used until I replaced that machine. I found Debian too difficult to install on my own, so I put Red Hat on my newer machine. At that time, yum didn't exist, and Red Hat only offered updates if I logged in to X as root, which I rarely did. So, it quickly became outdated, and OpenOffice 1.1 couldn't handle right-to-left text, which I needed for one of my university classes. So, I started using my Windows XP laptop most of the time. I couldn't install Linux on the laptop because the NTFS tools of the era couldn't resize my partition. After a couple of years, I decided to switch my Red Hat box to something more modern. I wanted to move away from the RPM package format, so I tried installing Debian again and once again found it too complicated to get all the features I needed. Then, I read about an up and coming Debian-based distro called Ubuntu that had just released their latest version. So, I installed 6.06 (Dapper Drake) and have used Ubuntu exclusively as my main OS all my machines since that time. I only boot into Windows a few times a year. I've tried a few other distros' live CDs, but so far have always decided that the benefits of those distros aren't significant enough for me to switch over. For the first many years, I used the command line most of the time, as early Linux GUIs weren't up to many basic tasks. These days, the GUI tools have made leaps and bounds and are quite usable. Nevertheless, I often prefer the command line for many tasks. I'm much more likely to use vim than Gedit. But, I quite appreciate GUI tools for a number of tasks--perhaps most tasks these days. SOreadytohelp

Updated on September 18, 2022

Comments

  • Scott Severance
    Scott Severance over 1 year

    One of my most popular answers is instructions on how to repair grub. Over time, others have contributed bug fixes to the answer. A recent comment, though, made me wonder if it works on newer UEFI hardware.

    Gabor wrote:

    I get a "cannot find EFI directory" at step 7 and cannot boot. Any ideas?

    All my hardware is older, pre-UEFI hardware. So my question is this: Are my instructions, particularly step 7, applicable to UEFI hardware? If not, what changes need to be made?

  • Pentaquark
    Pentaquark over 2 years
    Hi, thank you for your answer! Quick question: is there a way to change the boot order in the BIOS directly, or from an Ubuntu Live stick? If so, would this render the use of EasyUEFI superfluous?