Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 '14 at 5:14
up vote 185 down vote accepted

When you install Windows, Windows assumes it is the only operating system (OS) on the machine, or at least it does not 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 is really clean.

Here's how:

  1. Boot from the live CD or live USB, in "Try Ubuntu" mode.
  2. Determine the partition number of your main partition. GParted (which should already be installed, by default, on the live session) 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  #Replace sda2 with your partition number
  4. Bind mount some other necessary stuff:

    for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
  5. chroot into your Ubuntu install:

    sudo chroot /mnt
  6. At this point, you're in your install, not the live session, 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: wrong ELF class: ELFCLASS32 error on 6th step after executing update-grub command. – Eray Apr 18 '12 at 22:49
I just want to mention that you should do the optional step, because even if you don't get errors, that step ensures that the MBR is rewrote on the /dev/sda, which is mostly what you want to do here. – John M Jan 23 '15 at 20:06

The Windows installer doesn't care about other OS in the system. So it writes own code over the master boot record. 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:

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

Use Recomended Repair.

enter image description here

More info -

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 '14 at 16:14

I never got in trouble by using these instructions:

First of all, you must start your system from a live cd. Then


This method of installation uses the chroot command to gain access to the broken system's files. Once the chroot command is issued, the LiveCD treats the broken system's / as its own. Commands run in a chroot environment will affect the broken systems filesystems and not those of the LiveCD.

1) Boot to the LiveCD Desktop (Ubuntu 9.10 or later). Please note that the Live CD must be the same as the system you are fixing - either 32-bit or 64-bit (if not then the chroot will fail).

2) Open a terminal (Applications > Accessories > Terminal).

3) Determine your normal system partition - (the switch is a lowercase "L")

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

5) Only if you have a separate boot partition: sdYY is the /boot partition designation (for example sdb3)

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

sudo chroot /mnt 

8) If there is no /boot/grub/grub.cfg or it's not correct, create one using


9) Reinstall GRUB 2:

Substitute the correct device - sda, sdb, etc. Do not specify a partition number.

grub-install /dev/sdX 

10) Verify the install (use the correct device, for example sda. Do not specify a partition):

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. – belacqua Nov 3 '12 at 20:25
+1 for cautioning on the separated /boot partition. – qed Mar 19 '13 at 15:27
I've done this several times on different systems and agree that the results speak for themselves (although I too skip the umount). – Elder Geek Feb 25 '15 at 14:32

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
Web-E already gave this answer. Maybe improve that one instead? I left a comment on why it didn't work. – Dan Dascalescu Feb 2 at 16:59

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 '14 at 20:46
easyBCD allowed me to add and remove boot options that I could see in both Windows Boot Loader and BIOS, but they never worked because easyBCD relies on some sort of automated magic to find Linux partitions... it didn't work when my Linux partition was on a separate harddrive. – fuzzyanalysis Dec 30 '14 at 12:14

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
This ended up being the cleanest option for me. It's a few more key strokes, but hey, it works. I have a mix of Legacy and UEFI booted devices. If users are booting one OS much more than an assortment of others, this can be faster (and safer) over the long run. – fuzzyanalysis Dec 30 '14 at 12:21

protected by jokerdino Dec 2 '13 at 17:55

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

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

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