-1

So I changed the boot mode in my BIOS from UEFI to Legacy for a completely unrelated project (a Linux distro on my USB). Now I want to go back to using Windows on my internal HDD however when booting in UEFI I get the error "No bootable media found" and when booting in legacy I only get recovery options in Windows. How can I fix this?

  • 2
    What all did you do between the time you enabled legacy mode and returned to UEFI mode? – Twisty Impersonator Apr 23 '17 at 20:38
  • @Twisty I booted Linux off of the usb and then restarted my computer when I was finished. I may have tried to boot windows in legacy mode, but I don't know if that matters. – Squid Apr 23 '17 at 22:44
1

You should first be aware that you can't simply switch the Compatibility Support Module (CSM; the firmware component that provides "legacy" boot support) off and on and expect to boot an installed OS in either mode. In order to boot in EFI mode, the OS must have an EFI-mode boot loader installed; and to boot in BIOS mode, the OS must have a BIOS-mode boot loader installed. Most OS installations put just one boot loader, for BIOS mode or for EFI mode, on the hard disk, but not two. To make matters worse, Windows ties its boot mode pretty tightly to its partition table type -- to boot in EFI mode, the disk must use the GUID Partition Table (GPT), and to boot in BIOS mode, the disk must use the Master Boot Record (MBR) partition table. There are some ways around these limits, but they're awkward and you almost certainly are not set up to use them. It sounds like your computer was booting Windows in EFI mode, so your goal should be to get it booting in EFI mode once again. (Incidentally, most Linux distributions these days also support EFI-mode booting, so enabling your CSM may not have been necessary. That leads into a long digression, though, so I won't say more on this subject.)

That said, the problem you describe should not have happened. My guess is that your firmware is buggy and did one of two things:

  • Deleted your Windows boot entry -- To boot in EFI mode, EFIs maintain a list of boot entries in NVRAM. It's possible that, when you switched to BIOS/CSM/legacy mode, your firmware deleted the EFI-mode entry for Windows. If so, then with that entry gone, your computer can no longer boot Windows in EFI mode. The solution to this problem is to re-create this boot entry.
  • Changed your boot order -- A single computer can have multiple NVRAM boot entries, so a boot order is also stored in NVRAM. Importantly, these entries can include both BIOS-mode and EFI-mode boot entries. It's possible that your firmware re-ordered these entries, putting a BIOS-mode entry at the top; and despite the fact that you've disabled BIOS-mode support, the computer is still trying to boot using that entry and failing.

Both these problems can be fixed in Windows, and the second may be fixable in your firmware setup utility, but details vary. As that's a relatively easy fix, though, I recommend you poke around in the setup utility for a way to adjust the boot order. The Windows entry is called "Windows Boot Manager." Be sure it's first in the boot order list. You should also review other settings; enabling your CSM may have automatically toggled something else that you need to switch back. Unfortunately, such details tend to be highly machine-specific, so you may need to ask on a forum dedicated to your brand of computer or motherboard.

If that fails, then there's probably a way to fix this with a Windows emergency disk; however, I'm not very familiar with such tools, so I can't tell you how to do it. I can, however, suggest a workaround that should get you booting temporarily and use Windows' regular tools to fix the problem:

  1. Disable Secure Boot on your computer. Details vary from one system to another; but see this page of mine for some examples of how to do it. (You can re-enable Secure Boot when you're done.) Note that not all computers support Secure Boot, but almost everything that shipped with Windows 8 and later does.
  2. Download the USB flash drive or CD-R version of my rEFInd boot manager. Download links for both types of media are on that page.
  3. Prepare a bootable medium from the rEFInd image you download.
  4. Boot using the rEFInd medium. It should detect your Windows installation and enable you to boot it.
  5. In Windows, open an Administrator Command Prompt window and type bcdedit /set {bootmgr} path \EFI\Microsoft\Boot\bootmgfw.efi. This should create a new Windows boot entry and make it the default.

When you reboot, the computer should boot back to Windows. If it doesn't, chances are you've overlooked something in your firmware, so triple-check its settings.

Once you've got Windows booting again, I recommend you re-enable Secure Boot, if you had to disable it to follow my suggested procedure.


EDIT: Upon seeing your Boot Repair output, it appears that your original Windows installation was in BIOS/CSM/legacy mode, not in EFI/UEFI mode, as I'd been led to believe by your comment about switching from UEFI-mode to BIOS-mode booting to boot Linux on a USB drive. This fact changes everything, and you should ignore most of my answer prior to this edit. (I'm leaving it in place as a record of our discussion so far, and because it includes information on the perils of switching between boot modes.)

Instead of trying to get EFI-mode booting of Windows working (which would be very difficult), I recommend you re-enable the CSM ("legacy" boot support) in your firmware and fix the Windows boot by using Windows tools. I'm not an expert on this process, so I can't help much. I don't know what caused the Windows boot to fail, but the repair process is going to be very Windows-specific and follow the pattern for older (most pre-2012) Windows installations, not newer EFI-mode installations.

  • I can go to "add boot options" and navigate through my HDD. What file should I be looking to add? edit: I have your rEFInd tool, how do I use it to boot Windows? – Squid Apr 28 '17 at 1:22
  • The Windows boot loader is EFI\Microsoft\Boot\bootmgfw.efi, so if you can add a boot loader in the firmware, try that one. If you've got rEFInd on a CD or USB drive, boot it (use the firmware's built-in boot manager to select the external medium). With rEFInd booted, it should show an option to boot Windows, and possibly other options, too. – Rod Smith Apr 28 '17 at 17:39
  • rEFInd just boots and I get a shell, I have no idea what I need to do. – Squid Apr 29 '17 at 0:32
  • So you don't see a Windows icon on the rEFInd screen? That could mean you've accidentally wiped out your Windows installation. To get better diagnostic information, please run the Boot Repair utility from a Linux emergency disk and select the "Create BootInfo Summary" option. (DO NOT click "Recommended Repair," at least not yet!) When asked whether to upload the report, click "Yes," and then post the URL provided here. This will give us more details about your configuration. – Rod Smith Apr 29 '17 at 19:15
  • paste.ubuntu.com/24508144 here's the summary from Boot Repair – Squid May 3 '17 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.