79

After I deleted my Ubuntu partition, I rebooted my computer and I only get a prompt:

grub rescue >

The command ls lists

(hd0) (hd0,msdos5) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1) (hd1) (hd1,msdos1)

I check them one by one:

ls (hd0,msdos5)/
ls (hd0,msdos1)/

But I cannot find the right partition.

karel
  • 114,770
user302065
  • 791
  • 1
  • 7
  • 3
  • Do you have another linux installation on your computer? – Dalton Jul 09 '14 at 22:09
  • 1
    No, just ubuntu 13.04, but dual with win 7 – user302065 Jul 09 '14 at 22:25
  • And when I tried rebooting by usb or dvd, it said " Error loading operating system" – user302065 Jul 09 '14 at 22:28
  • It's unclear what you are asking. Please define "right partition" Are you trying to recover a partition that you accidentally deleted? – Elder Geek Jul 09 '14 at 23:53
  • I can't post an answer so I write my answer her: create a ubuntu bootable USB, then launch ubuntu from the USB, launch ubuntu terminal and write sudo apt-get install syslinux ENTER and then sudo dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda. To create a bootable USB : http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-windows, to launch ubuntu from the usb, press F11 or F12 when your computer boot (before windows start). To launch ubuntu terminal Ctrl - Alt + T – MagTun Nov 17 '15 at 13:34

4 Answers4

118

Try the following ..

grub rescue > ls
(hd0) (hd0,msdos5) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1) (hd1) (hd1,msdos1)
grub rescue > ls (hd0,msdos1) # try to recognize which partition is this
grub rescue > ls (hd0,msdos2) # let's assume this is the linux partition
grub rescue > set root=(hd0,msdos2)
grub rescue > set prefix=(hd0,msdos2)/boot/grub # or wherever grub is installed
grub rescue > insmod normal # if this produced an error, reset root and prefix to something else ..
grub rescue > normal

For a permanent fix run the following after you successfully boot:

sudo update-grub
sudo grub-install /dev/sdX

where /dev/sdX is your boot drive.

David Foerster
  • 36,264
  • 56
  • 94
  • 147
Amr Ayman
  • 1,359
  • 1
  • 7
  • 10
  • 12
    grub rescue > ls (hd0,msdos1) # try to recognize which partition is this -----> I am getting error : Unknown filesystem in each of the three partitions I get listed by the ls Command.Please help.Thanks. – Rafed Nole Jul 10 '14 at 13:28
  • 5
    the ls commands should be like "ls (hd0,msdos1) /boot" – Aakash May 29 '15 at 20:06
  • this worked for me as well! but next time when i restart the machine i had to issue the same commands again. how do i resolve that? – samsamara Jul 13 '15 at 06:41
  • @KillBill: insmod inserts the normal module to kernel using the root and prefix variables that are responsible for configuring the boot operation. A solution I can think of is to use the enhanced version of insmod, modprobe and run: modprobe normal from your installation. I don't really expect this to work, just tell me what output you get. – Amr Ayman Jul 14 '15 at 05:36
  • 3
    thanks for the reply. but i fixed it by login in through a live USB and issuing 'update-grub' command – samsamara Jul 14 '15 at 08:08
  • This works and I'm able to boot. But I face this problem every time I boot, and I have to repeat this.

    How do I make this solution permanent?

    – ArcaneDominion May 27 '16 at 11:51
  • @Jim See comment above – Amr Ayman May 27 '16 at 11:53
  • @AmrAyman I did run update-grub upon booting, but not from a live USB. That didn't fix the problem. – ArcaneDominion May 27 '16 at 11:54
  • @Jim issue 'grub-install' after that. – Amr Ayman May 27 '16 at 11:56
  • Great instructions, got my system back up and running in a couple of minutes thanks! – Gondrup Apr 09 '17 at 08:51
  • @AmrAyman, after I tried those 2 last commands, no success. I have to repeat every time. Do you have idea? – Sigur May 16 '17 at 01:21
  • 1
  • Fantastic! It works. One helpful thing would be that you can type ls (hd0,msdos1)/ (the trailing slash is important) in order to actually show you the files on the drive. – mgiuca Dec 22 '17 at 07:58
  • 5
    I tries 'ls (hd0,msdos1) /boot' for all. it shows 'unknown filesystem'. what should I do? Please help – Anusha Prasanth Jan 22 '18 at 11:43
  • On the machine I try to rescue, I find (hd0,msdos1)/grub/grub.cfg, accordingly set root=(hd0,msdos1) and set prefix=(hd0,msdos1)/grub but insmod normal only gives me an error: file not found.. What gives? – Giszmo Apr 15 '18 at 20:12
  • Worked exactly as described on a dual boot PC with Ubuntu 14.04 and Windows 7 after removing an empty partition, thanks a million! NB: for finding the boot drive, see https://askubuntu.com/a/542360/438017 – lmeurs Feb 02 '19 at 22:10
39

To remove GRUB just download Windows 8 or 10 from another PC. Burn the iso into the USB with Rufus. Boot from USB, click Troubleshooting, then Command Prompt, and type:

Bootrec /fixmbr  

Windows will start normally without Ubuntu's GRUB. You can reinstall Ubuntu again.

  • I run the command without the dot at the end:Bootrec /fixmbr – draw Mar 26 '17 at 20:43
  • I had the same problem and after a day of searching and trying I think this is the best solution in this case. I have win 10 (UEFI) which works normally. I want to remove grub resuce from my legacy bios and install a new Ubuntu there. However, my laptop does not have CD-ROM. I had created a bootable USB for Ubuntu that worked perfectely for me before. But now the grub rescue refuses to acknowlege it and says uknown filesystem for all the partitions (including the inserted USB). I believe I would have the same problem with bootable USB for windows. So how can I get rid of grub rescue? – Yasser Mohseni Nov 03 '17 at 12:27
  • 1
    It seems that you are not booting from USB correctly! Select your usb from BIOS settings before grub appear! –  Nov 03 '17 at 16:13
  • Can I legally install Windows 7 this way? I have Windows 7 recovery partition and I am both unable and uninterested in installing Windows 8 on that computer. – reducing activity Nov 17 '19 at 14:43
  • 2
    It's very important circa 2020 to recognize that fixmbr commands will restore an MBR style boot. If you had UEFI before, it would now be MBR again. I don't see many correct answers floating around, so if you've already fallen into that place, you should look into Windows' mbr2gpt program which is part of the WinPE bootable. It's an absolute PAIN to use, but it works to get your disk back to GPT/UEFI. It possibly also has repair tools to restore a UEFI setup supposing you didn't run fixmbr. –  Apr 24 '20 at 02:26
  • Boot from USB -> "Repair Windows" instead of "Install Windows", then "Trouble Shooting". – mon Jan 30 '21 at 10:01
6

Boot your computer on a Ubuntu live-CD or live-USB

then follow the section 2nd option : install Boot-Repair in Ubuntu from this link:

https://help.ubuntu.com/community/Boot-Repair

Zanna
  • 70,465
  • 3
    I tried this. It claimed to have repaired it, but it just keeps putting me back to a grub terminal. – astromax Aug 11 '15 at 23:26
  • I tried boot-repair and still got black screen. In my case the problem was boot-repair attempted to repair my SD-card on laptop (based on log). So I removed the card from PC and re-ran boot-repair, then the boot was repaired. – hakatashi Jul 14 '18 at 16:08
2

I did the same thing. Deleted Ubuntu partition. I am able to enter into BIOS.

If you have a bootable USB for Ubuntu, enter BIOS and choose the USB first in boot sequence. Restart. Then install Ubuntu again. And you can delete SAFELY this time.

atilkan
  • 260