Take the 2-minute tour ×

I installed Windows 7, which ate Ubuntu's boot file. When starting up the computer, it now goes straight to Windows, without giving me the option of booting Ubuntu.

How can I get Ubuntu back?

share|improve this question
I think it is a common task, I also have two HDDs, and Ubuntu+Windows. I hope you can repair it with the right way. Try to follow this tutorial. Any questions, ask me! –  B. Roland Dec 17 '11 at 7:24
Related (when GRUB was installed to the wrong drive's MBR): Grub rescue problem after installing ubuntu –  Eliah Kagan Jan 21 '13 at 4:20
Yes you can, you would just have to do a normal boot and install with windows and then it should show up in the Grub boot menu at the start-up of the computer. –  Rampoo1208 Jul 30 '13 at 18:51
I know this is an old thread but I fixed the problem by changing the boot mode in the bios from UEFI to Legacy. –  user183708 Aug 13 '13 at 11:32
NOTE: the accepted answer is a general instruction on how to repair grub. It is also applicable to the wide variety of circumstances when GRUB is written incorrectly by the installer (ubiquity). –  Danatela May 14 at 5:14

9 Answers 9

up vote 124 down vote accepted

When you install Windows, Windows assumes it's the only OS on the machine -- or at least it doesn't account for Linux. So, it replaces GRUB with its own boot loader. What you have to do is replace the Windows boot loader with GRUB. I've seen various instructions for replacing GRUB by mucking around with GRUB commands or some such, but to me the easiest way is to simply chroot into your install and run update-grub. chroot is great because it allows you to work on your actual install, instead of trying to redirect things here and there. It's really clean.

Here's how:

  1. Boot from the live CD.
  2. Determine the partition number of your main partition. GParted can help you here. I'm going to assume in this answer that it's /dev/sda2, but make sure you use the correct partition number for your system!
  3. Mount your partition:

    sudo mount /dev/sda2 /mnt  # make sure that sda2 is correct!
  4. Bind mount some other necessary stuff:

  5. chroot into your Ubuntu install:

    sudo chroot /mnt
  6. At this point, you're in your install, not the live CD, and running as root. Update grub:


    If you get errors, go to step 7. (Otherwise, it is optional.)

  7. Depending on your situation, you might have to reinstall grub:

    grub-install /dev/sda
    update-grub # I'm not sure if this is necessary, but it doesn't hurt.
  8. If everything worked without errors, then you're all set:

    sudo reboot
  9. At this point, you should be able to boot normally.

If you cannot boot normally, and didn't do step 7 because there were no error messages, try again with step 7.

  • Sometimes giving GRUB2 the correct configuration for your partitions is not enough, and you must actually install it (or reinstall it) to the Master Boot Record, which step 7 does. Experience helping users in chat has shown that step 7 is sometimes necessary even when no error messages are shown.
share|improve this answer
yeah .. finally it does work .. would you please explain what happened? –  Salahuddin Dec 17 '11 at 12:56
update-grub only generates the configuration file. To actually rewrite the boot sector, you need to run grub-install. –  Mihai Capotă Dec 24 '11 at 10:59
@MihaiCapotă: From the documentation it seems as though that would be the case. grub-install is good to know about. However, in my experience so far, update-grub has been sufficient. YMMV. –  Scott Severance Dec 24 '11 at 13:09
@ScottSeverance , i'm getting /usr/sbin/grub-probe: error while loading shared libraries: libdevmapper.so.1.02.1: wrong ELF class: ELFCLASS32 error on 6th step after executing update-grub command. –  Eray Apr 18 '12 at 22:49
@Eray: Never heard of that problem. Is the live CD the same version of Ubuntu as your install? If not, that might be the problem. Or maybe you've got a 32-bit install and a 64-bit CD or vice-versa. The CD needs to match your install. –  Scott Severance Apr 18 '12 at 23:26

The windows installer doesn't care about other OS in the system. So it writes own code over the master boot record. Its not a problem of windows installer, its intended. If you reinstall, upgrade windows you will face the issue. Fortunately the solution is easy too.

You need to repair the mbr. Do the following

Boot using a live usb/cd of ubuntu. Use boot-repair to fix the problem.

After booting with live usb/cd ,Run following command in terminal,


Use Recomended Repair.

enter image description here

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

share|improve this answer
you mean to say its intentional by the Microsoft people?? Also dual booting did work with windows 7 so doesn't it contradict your first line that "The windows installer doesn't care about other OS in the system." –  Shagun Sep 1 '12 at 7:04
Windows breaks grub all the time its a really common issue and one ive had to deal with myself. The answer is still good and should fix the problem. –  damien Sep 1 '12 at 7:18
you have installed windows 7 first then linux. So linux recognize windows not windows recognized linux. Ttry reinstalling windows7, you will see what I meant. –  Web-E Sep 1 '12 at 7:26
ohk now I get what you meant :) –  Shagun Sep 1 '12 at 7:46
Don't do this when you have encrypted partitions (luks), it messed it up. It also reinstalls GRUB with apt-get - no idea why it's doing that. –  Meng Tian Jan 5 at 16:14

I never got in trouble by using these instructions:







sudo fdisk -l

If you aren't sure, run

df -Th  

Look for the correct disk size and ext3 or ext4 format.

4) Mount your normal system partition:

Substitute the correct partition: sda1, sdb5, etc.

sudo mount /dev/sdXX /mnt  

Example: sudo mount /dev/sda1 /mnt


sudo mount /dev/sdYY /mnt/boot 
6) Mount the critical virtual filesystems:
sudo mount --bind /dev  /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys  /mnt/sys 
7) Chroot into your normal system device:

sudo chroot /mnt 



9) Reinstall GRUB 2:


grub-install /dev/sdX 


sudo grub-install --recheck /dev/sdX 

11) Exit chroot: CTRL-D on keyboard

12) Unmount virtual filesystems:

sudo umount /mnt/dev/pts
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys 

13) If you mounted a separate /boot partition:

sudo umount /mnt/boot 

14) Unmount the LiveCD's /usr directory:

sudo umount /mnt/usr 

15) Unmount last device:

sudo umount /mnt 

16) Reboot.

sudo reboot 

share|improve this answer
Just a note that it isn't necessary to worry about unmounting stuff, because the reboot will take care of that automatically. Sending umount commands wastes time. –  Scott Severance Oct 1 '12 at 8:44
sudo umount -a should take care of them, as well. It's not a bad practice if you've got the few moments. At least reminds you of what's going on, and in some (corner/marginal) cases it can keep the reboot from stopping to warn you or wait for input. –  belacq Nov 3 '12 at 20:25
+1 for cautioning on the separated /boot partition. –  qed Mar 19 '13 at 15:27

Boot from a live Ubuntu USB pendrive or CD and
Install Boot-Repair on ubuntu by following steps

Open the terminal and run the following commands

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install boot-repair

After completing the installation you can launch it from System->Administration->Boot-Repair menu if you use Gnome, or search "boot-repair" in the dash if you use Unity. Then follow the following screenshots:

Method 1

  • Click on the advanced options

Initial screen

  • Tick the options shown below

advanced option

  • Change the tab to Grub Location Tab and Tick The options Shown in the figure

enter image description here

Press Apply and Reboot the system

Method 2

  • Select the recommended Boot repair options as shown in the first screenshot

Documentation :

share|improve this answer

Just install easyBCD in Windows 7 and do

Add New Entry > Linux/BSD > (select ) Grub2 > (push) Add Entry

Then you can choose Ubuntu on the Windows 7 bootloader to go to Grub2 (previous bootloader).

share|improve this answer
These instructions alone do not restore the Grub Bootloader - when I tried them, they added an extra boot option in Windows which on selection, restarted my machine and then took me to a grub> prompt. So one would need further steps as to what to do next. –  therobyouknow Jun 15 at 20:46

Boot-Repair worked for me. It's very very easy to use graphical application, you do not need to use the command line, you only have to click a button :)

All the available repair options are described in the Ubuntu documentation and there is a separate page explaining how to start Boot-Repair (by creating a bootable disk or installing it in an existing Ubuntu live disk) and how to use it.

Just boot a Ubuntu live CD, install Boot-Repair and run it.

share|improve this answer
It would be nice if there were an easier way to get Boot Repair, though. It's faster to just set up a chroot repair than to Google around for some other tool to install. –  Scott Severance Dec 18 '11 at 1:51

When GRUB is broken, the user generally does not have access to systems, so repair must be performed from a live-session (live-CD or live-USB).

There are many possible causes to a GRUB break: Windows writing on the MBR, DRM preventing GRUB from installing correctly, installer bug, hardware change... Updating GRUB as proposed initially by Scott is generally not sufficient, reinstalling GRUB as proposed by Marco is more efficient, but still there are various situations requiring other tweaks (adding options to kernel, unhiding GRUB menu, changing GRUB options, choosing the right host architecture...). Other difficulties for repairing GRUB is the use of chroot, and the choice of the right partitions /disks.

All of this has been made easy in a little graphical tool: Boot-Repair. It shall be integrated in Ubuntu 12.04 CD for easier use, but for people needing it now, there are already some distros integrating it: Ubuntu-Secured-Remix (Ubuntu CD integrating Boot-Repair), Boot-Repair-Disk (CD running Boot-Repair at start-up), ...

Hope this helps.

share|improve this answer

Windows does not see Linux formatted partitions. You need to use gparted from a liveCD and create a primary partition formatted NTFS with the boot flag.

Some have had issues if the new primary partition is after the extended partition as Windows does not always reset partition table correctly. Best to have good backups and a separate backup of partition table.

Backup partition table to text file & save to external device. sudo sfdisk -d /dev/sda > PTsda.txt

This is only for MBR(msdos) systems. If your Ubuntu install is in gpt partition drive you can only install Windows in UEFI mode or convert drive back to MBR(msdos).

share|improve this answer

There is now a simpler solution:

  1. Reboot, and enter your computer's BIOS options (F2, or sometimes F11).
  2. Go to the Boot menu, and select Boot Device Priority
  3. Check if Windows Boot Manager is above the main boot drive (usually SATA HDD … or IDE HDD …). If it is, move the boot disk priority above that of Windows Boot Manager.
  4. Save your BIOS options, and exit (usually F10).

This has been tested on a Samsung Series 7 Chronos laptop dual booting Windows 8 and Ubuntu 13.10, secure boot disabled, UEFI and legacy boot enabled.

share|improve this answer

protected by jokerdino Dec 2 '13 at 17:55


Would you like to answer one of these unanswered questions instead?
