This question already has an answer here:

I had Ubuntu 14.04 LTS on my system, fresh install from a live USB. I was messing around with partitioning, trying to set up room for windows. Ended up deleting my ubuntu partition and rebooted. Now all boots fail.

When booting to hard disk, it gives me grub rescue. When booting from live CD, it does the same thing. When booting from live USB, it gets to loading operating system and sits there for 30mins before I give up.

ls command returns:

(hd0) (hd1) (hd1,msdos1)

Tried a few other commands, no luck. I have no data in there that I'm worried about, would like to start fresh now that I know a bit more about what I'm doing. Booting from Live USB/CD is not an option for me. Also tried Grub repair disk. I've been using Unetbootin to create disks and USBs.

Any other way to fix grub?

marked as duplicate by Eric Carvalho, Tim, waltinator, Luís de Sousa, Maythux Jul 14 '15 at 10:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • If Ubuntu partition is gone, there is no way to boot from just the small part of grub that is in MBR. Most of grub is in Ubuntu partition. And MBR should just be replaced when you do a new install or install Windows. But you have to go into BIOS and boot CD, DVD or flash drive that are configured as bootable installers or repair disks. – oldfred Jun 13 '15 at 3:36
  • Thank you for the input. I have no problems booting from a USB in my bios screen. However; my machine never makes it past "Loading operating system". I know that my grub is dead, but it seems that it's also preventing me loading anything else from BIOS. Is my hard drive broken for good? – Chris Jun 13 '15 at 3:47
  • Systems will boot live installer without even a hard drive, so hard drive with non-working grub should not prevent booting of USB flash drive or DVD. But make sure you have working bootable flash drive or DVD. – oldfred Jun 13 '15 at 12:10
  • Have you tried using boot repair? – Amith KK Jul 13 '15 at 6:22

To help you (and perhaps others) avoid the problem in the future, you should first understand what happened. With that information in hand, you can recover your system and remove Ubuntu properly in the future (should the need arise again)....

What Happened?

Most Ubuntu installations, on both BIOS-based and EFI-based systems, split GRUB across two or more locations:

  • The main GRUB binary -- This code is run by the firmware. Importantly, it does not reside in the Ubuntu root (/) or /boot partition. On BIOS-based computers, it resides in the first few sectors of the hard disk (or if the disk uses GPT, in the first sector of the disk and in the BIOS Boot Partition). On EFI-based computers, it resides in the EFI System Partition (ESP). This means that the main GRUB binary will not be erased when you delete an Ubuntu partition, and the firmware will continue to boot it; however....
  • GRUB support files -- In most cases, GRUB loads its configuration file and other support files from the Ubuntu /boot/grub directory. This directory is deleted when you delete an Ubuntu installation.

The result is that when you delete an Ubuntu partition, GRUB can launch, but it can't do anything, because it's been figuratively lobotomized.

That said, one thing about your story is puzzling: You say that you're no longer able to boot from a USB drive. An Ubuntu installer image is designed to be self-contained; it does not rely on the contents of your hard disk, and should not be affected by the state of GRUB (or anything else) on that disk. You must be running into some unrelated problem -- maybe some RAM has gone bad since you did your initial installation; or you're trying to boot a different version of Ubuntu that doesn't like your video card; or you prepared the USB drive incorrectly. These are just wild guesses, though; there are about a million possible reasons why a boot from a USB drive might fail. In any event, I recommend you try other Linux distributions or prepare your medium using another program to work around this problem. If necessary, post a new question with more details about that aspect of the problem if you can't get it to work.

How to Recover

Recovering your system involves installing a working boot loader on your computer. It sounds like yours is BIOS-based, so this means modifying the MBR. If you want to make your Windows bootable again, the best approach is probably to use a Windows recovery tool. There are Windows procedures for restoring an MBR, but I don't recall the details. A Google search turned up this tutorial, but there are 658,000 others in my search, so try your own search if that procedure doesn't work for you.

Another option is to re-install Ubuntu (or any other OS, really). As part of the OS installation process, a new boot loader will be installed. If you re-install Ubuntu, that boot loader will be GRUB, and the installer should detect Windows and make it an option in the GRUB menu.

One caveat is to watch your boot mode (BIOS vs. EFI); you don't want to mix them. It sounds like you've got a BIOS-mode Windows installation, so you do not want to install Ubuntu in EFI mode. If your computer is from before 2011, chances are this won't happen, since EFIs started to become common only in mid-to-late 2011. If you've got a more recent computer, though, you may need to be careful. After booting your installation medium but before installing, drop to a shell and look for a directory called /sys/firmware/efi. If it's present, you've booted in EFI mode; if it's absent, you've booted in BIOS mode. If you've booted in the wrong mode, try again, but pay attention to boot menu options. Typically, external media have two options, one with the string "UEFI" and one without it. The one with the "UEFI" identifier boots in EFI mode and the one without boots in BIOS mode.

How to Not Do This Again

If you need to remove Ubuntu again on a BIOS-based computer, it's best to restore a non-Ubuntu boot loader to the MBR before you delete the Ubuntu partition(s). You can use a Windows recovery disc to do this, or there are ways to do this from Ubuntu, as described here (among other places).

On an EFI-based computer, you can use efibootmgr to change the boot order before you delete the Ubuntu partition(s). Type sudo efibootmgr alone to see the options, then identify the Windows (or other OS's) boot entry number from the list, and use the -o option to set it first in the list, as in sudo efibootmgr -o 2,7 to boot Boot0002 first and to boot Boot0007 as a fallback. Another option is to delete the /boot/efi/EFI/ubuntu directory from Ubuntu immediately before you wipe out the Ubuntu partition(s).

On either type of computer, another option is to set your boot loader up in a way that can survive the removal of Ubuntu. One way to do this is to use a separate Ubuntu /boot partition, but to not delete it along with the main Ubuntu partition. Then GRUB will continue to operate, although it will present non-functional Ubuntu options and, in the absence of a Linux installation, it will be difficult to change its boot options. There are ways to set GRUB up on a FAT partition in an OS-independent way. The GRUB4DOS boot loader can be used on a BIOS-based computer, for instance. On an EFI-based system, alternatives like gummiboot or my own rEFInd don't rely on Ubuntu partitions, and can be used instead of or in addition to GRUB.

  • Thank you for the detailed reply. I'll try a few different OS and methods for USB boot, not sure what the real problem is anymore. Will create a new question if I need to, when I know more. – Chris Jun 13 '15 at 15:26

I believe you can use unetbootin to create a bootable usb thumbdrive from a bootable cdrom image. I have done this.

If you go to this page and download the iso image for a bootable cdrom of the boot repair utility and make that boot repair thumbdrive, you can painlessly restore grub to your hard drive.

You may be interested to know that I have such a boot repair thumbdrive in my emergency repair kit. It can be extremely handy!

  • Thanks for the reply! Unfortunately, I have tried that step. Tried both USB and burned CD boot from that ISO. Other solutions on this topic all mention creating a bootable CD or USB. My system stops at Loading Operating System... – Chris Jun 13 '15 at 3:12
  • there is more than one version of the boot repair bootable media, one aimed at older systems. Also, among those for newer computers, there are both 32 and 64 bit versions and you have to use the correct version for your installation. Please tell us more about your system. laptop or desktop, 32 or 64bit hardware, 32 or 64 bit ubuntu? Perhaps most important, are you using this computer in an air conditioned environment and what is the temperature there. When computers around here act up this time of year, it is often a matter of accumulated dust and ambient temperature combined. – gyropyge Jun 13 '15 at 3:19
  • Well this all started when I was dumb and put a 32bit ubuntu on my 64bit desktop. Checked temperatures in BIOS, everything seems fine. I'm also not running it for very long... Tried both 63bit and 32bit boot repair disk. Tried fooling around boot order in BIOS, and tried burning iso to disk as well as unetbootin usb configuration... Thanks for the suggestions, I have a feeling I buggered it up beyond repair with the wrong OS business – Chris Jun 13 '15 at 3:45
  • No, not at all. depending upon configuration, 32bit OS can work better on 64 bit hardware. Don't jump to conclusions without first understanding why you may or may not want either one. I am runningg 32bit right now on a 64bit machine with 6cpu cores and 8gb ram. I suspect that the reason your boot repair isn't working right is you received a bad download. It has happened to me a few times. Download it fresh and try again. – gyropyge Jun 13 '15 at 3:49
  • It just dawned on me you may have been trying to use the 64bit version of boot repair. Please be sure to use the 32bit version. Better still, try this particular one which I have found to be more successful with 32 bit installations for reasons I don't dare to pretend to understand. sourceforge.net/projects/boot-repair-cd/reviews – gyropyge Jun 13 '15 at 4:25

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