The problem is caused by the fact that GRUB relies on a configuration file that's stored in the Ubuntu root (/
) or /boot
partition, /boot/grub/grub.cfg
. There are also GRUB modules (drivers) in the same location. When you deleted your Ubuntu partition, those files were rendered inaccessible.
Methods of recovering from this problem depend on whether the computer boots in EFI/UEFI mode or in BIOS/CSM/legacy mode.
EFI-Mode Booting
In this case, the solution is usually easy: You can use the computer's built-in boot manager to boot Windows directly. The tricky part is accessing the built-in boot manager, since how you do this varies from one computer to another. It's usually done by hitting a high-numbered function key (F8 or above) early in the boot process, but sometimes it's a lower-numbered function key, Esc, Enter, or conceivably something else. Look for boot-time prompts, check your manual, ask the manufacturer, or just try random keys from the set of keys I've mentioned. Occasionally a computer can be configured to disable the ability to enter this menu, or you might get into it and find that the Windows entry is missing. In such a case you may need to try more desperate measures. My own rEFInd boot manager, installed on a CD-R or USB flash drives (the preceding linked page has downlown links for both types of media) may be able to help in such a case. If you can get rEFInd to boot, it should show an option to boot Windows.
Once you've booted Windows, you can use the third-party GUI EasyUEFI to change the boot order, putting the Windows boot loader first. This should fix the problem. As an alternative to EasyUEFI, you could use the bcdedit
tool by typing the following command in an Administrator Command Prompt window:
bcdedit /set {bootmgr} path \EFI\Microsoft\Boot\bootmgfw.efi
The bcdedit
command creates a fresh entry, so this will work even if the Windows entry is missing from the built-in boot manager. (EasyUEFI can do this, too, but adjusting the boot order is more obvious in its GUI.)
BIOS-Mode Booting
This is the trickier case. Several solutions occur to me, but most of these require the use of external media with appropriate recovery tools:
- GRUB commands -- One method to temporarily boot Windows without extra tools is to issue the appropriate GRUB commands yourself at the
grub>
prompt. This Stack Exchange question and answers describes how to do this.
- Super GRUB 2 Disk -- The Super GRUB 2 Disk is an emergency recovery tool that should help you boot Windows, but you'll need to write it to a CD-R or USB flash drive to boot.
- Windows recovery tools -- If you can prepare a Windows emergency disk, you should be able to write the Windows boot loader to the MBR from a Command Prompt window by typing
BOOTREC /FIXMBR
. This command should also get things working permanently if you can boot your main Windows installation via one of the preceding methods. There may be other Windows-specific recovery tools or procedures, but I'm not an expert on them.
- Ubuntu recovery tools -- If you can boot an Ubuntu (or other Linux) emergency system, you may be able to write an MBR that bypasses GRUB and boots Windows directly. This page describes one way to do this.
- Re-install Ubuntu -- You can re-install Ubuntu to get a GRUB that works, thus restoring your ability to boot Windows.
- Undelete the Ubuntu partitions -- You can use a tool like TestDisk to recover your Ubuntu partition(s), thus restoring
grub.cfg
and other GRUB files and making GRUB work again. Of course, you'll need to boot an emergency disk to run TestDisk.
Most of these BIOS-mode approaches will also work with an EFI-mode boot, although some require tweaks. For instance, BOOTREC /FIXMBR
will not work on an EFI-mode installation; you'd instead use EasyUEFI or bcdedit
to do the equivalent.