Ubuntu – GRUB2 does not show Windows 8 option to boot into after Dual Boot

bootdual-bootgrub2uefiwindows 8

Yesterday, I tried to dualboot Ubuntu 16.04 onto my hard drive, creating a new partition for Ubuntu alongside my existing Windows 8. First, I disabled the fast-boot option in Windows 8, and still GRUB did not load, and it went directly to Windows boot-up. Then I did some research and found this article:

Grub not showing on startup for Windows 8.1 Ubuntu 13.10 Dual boot

Basically, I issued the BCDEdit command in Windows, and entered in the following code:

bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi

When I reboot, I get a basic GRUB2 terminal, and after I type in the exit command, then a second Shell prompt appears, and after typing the exit command again, the GRUB2 menu to select the OS to boot finally appears… with only Ubuntu and Ubuntu memory test as options, not Windows 8.

After booting into Ubuntu, I tried to run the Boot-repair Utility, but that shows this following error: Legacy Mode vs. EFI session

How do I approach this problem? The Pastebin log is here: https://pastebin.com/3NHMxxFh

Thanks for the help!

Best Answer

You're running into Compatibility Support Module (CSM; aka legacy-boot or BIOS-mode boot) issues. Most modern computers use Extensible Firmware Interface (EFI; usually Unified EFI, or UEFI, which is EFI version 2.x) firmware. EFI firmware is fundamentally different from the older BIOS firmware that dominated the PC industry from the 1980s to 2011. The CSM, though, provides a backwards-compatibility layer, enabling new EFI-based computers to boot old OSes. This is useful in some cases, but when used inappropriately, it causes a new set of problems, because you need to know how to control the boot mode, and that can be tricky. Even if you know what you're doing, there's so much model-to-model differences that predicting what a computer will do is next to impossible. For more on this subject, see my Web page on the CSM.

Your computer appears to have both BIOS-mode and EFI-mode versions of GRUB installed. I suspect (but am not 100% positive) that your computer is currently configured to boot into the EFI-mode GRUB, but this version is misconfigured. When you exit from it, you get an EFI shell prompt. When you exit from that, the BIOS-mode GRUB launches and enables you to boot Ubuntu. Your Windows, though, is installed in EFI mode, and the BIOS-mode GRUB can't launch the EFI-mode Windows.

If my analysis is correct, there are at least two good solutions to the problem:

  • Use rEFInd -- This method changes your main boot program from GRUB to rEFInd. Since rEFInd is EFI-only, disabling the CSM is not critical.
    1. Download the USB flash drive or CD-R version of my rEFInd boot manager.
    2. Prepare a medium from the files you download.
    3. Boot to the rEFInd medium. It should show options to boot both Windows and Ubuntu. (There are likely to be two Ubuntu options, one of which will launch your non-functioning GRUB and the other of which will boot correctly.)
    4. Test both the Windows and Ubuntu boot options.
    5. If you can boot both Windows and Ubuntu, boot to Ubuntu.
    6. Install the rEFInd PPA or Debian package.
    7. At this point, when you reboot, rEFInd should appear, even with the removable disk unplugged. You'll now boot through rEFInd, bypassing GRUB. You may want to tweak the rEFInd configuration, but that's another matter.
  • Use Boot Repair in EFI mode -- This method requires disabling the CSM, or at least learning to control your boot mode. You can then repair the EFI-mode GRUB.
    1. Boot into your firmware setup utility.
    2. Disable your CSM. Precisely how to do this varies from one machine to another. See my CSM page for some suggestions.
    3. Boot an Ubuntu installation disk in "try before installing" mode.
    4. Open a Terminal window.
    5. Look for a directory called /sys/firmware/efi. If it's present, you've booted in EFI mode and can continue; if it's absent, you've been unsuccessful in disabling your CSM and should try that again, or at least learn to control your boot mode, as described on my CSM page.
    6. Download and launch Boot Repair, as you've done before.
    7. Tell Boot Repair to repair your installation. As you've now booted in EFI mode, it should do an EFI-mode repair.
    8. Reboot and hope it works. With any luck, you'll see both Ubuntu and Windows options in the GRUB menu, and both should work. (See below for one more caveat, though.)

Use whichever of those methods sounds most appealing to you. If it doesn't work, use the other method -- but be sure to read the rest of this answer first.

In either of these cases, you should be aware that dual-booting Windows and Ubuntu can create problems if you fail to disable the Fast Startup feature in Windows. (Note that many EFIs have a feature with a similar name, but this feature is unrelated to the Windows feature and is much less troublesome.) The Windows Fast Startup feature turns shutdown operations into suspend-to-disk operations in order to speed up subsequent boots. This practice, though, causes filesystem damage to shared partitions in dual-boot scenarios. The ESP is a shared partition, so Fast Startup can cause damage to this partition. Symptoms include an assortment of boot problems, including a failure to launch GRUB, a failure of GRUB's configuration scripts to detect Windows, and an inability of GRUB to launch Windows even if a Windows entry appears in its menu. Similar problems can occur with rEFInd. Even if you don't run into these problems, you should disable Fast Startup, as described in the link at the top of this paragraph. If you do run into these problems, you should disable Fast Startup, and if you use GRUB, you may need to type sudo update-grub to have it update its menu after you've disabled Fast Startup.

Note that in Windows 10, it's often necessary to disable Hibernate, in addition to Fast Startup. AFAIK, this is not required with Windows 8.


EDIT:

Normally, rEFInd should show a graphical UI. If it can't read any icons, though, it drops back to a text-mode display like the one you've shown. Thus, I suspect that rEFInd is unable to read its icons -- and probably not its filesystem drivers, either; if it could read the drivers, you'd probably see an entry to launch your Linux kernel directly. Did you use the CD-R or USB flash drive image, and how did you prepare your boot medium from the image? It could be there was a problem with the way you did this, or the filesystem might have been damaged or be in some way unappetizing to your particular firmware.

As a workaround, try downloading the .zip file and, in Linux, do this:

  1. Prepare a USB flash drive with a fresh FAT filesystem. (You can start with something you've got on hand or partition a USB drive with GParted or some other tool. Try to make it a disk-spanning partition.) It's best if it use the GUID Partition Table (GPT) and the FAT partition be marked as an ESP (gdisk type code EF00 or a "boot flag" set in GParted or parted); but it will probably work if it uses MBR and is not marked as an ESP.
  2. Unpack the rEFInd .zip file and cd into the resulting directory
  3. Type sudo ./refind-install --usedefault /dev/sdd1 --alldrivers, changing /dev/sdd1 to the device filename for your USB flash drive's FAT partition. This should create a fresh rEFInd install on the disk with all the necessary files.

You should be able to boot with this disk. If it still doesn't work, then something very odd is going on. You might try changing the partition table format on the USB disk (use MBR instead of GPT, or vice-versa).

Of course, you could also try the Boot Repair approach instead of trying to get rEFInd to work.

Related Question