Repairing Grub after Windows Breaks It

Recently I built my dad a dual boot system with Ubuntu 10.04 and Windows XP. He likes his games so he wanted to keep a Windows installation for gaming. Fine. Built, tested, delivered.

However, he had a bad video card (and some other issues) and he had a friend help him at various stages. He lives on the other side of the state with a mountain range in between us so I understand.

Anyway, to make a long story a little shorter and to emphasize my confusion, I received the machine in the following condition. First, Windows 7 had been installed. This of course broke all that I had done with my dual boot. My Ubuntu installation, which had been controlling boot loading with Grub, was borked and the Windows 7 installation was on what appeared to be a failing hard drive. Instructions? Make it work.

First thing I did was just to reinstall Ubuntu so as to take control of boot loading again and since it was a fresh installation anyway, why not? Then I used GParted to move the partitions around to make room for the Windows 7 installation on the same drive where the other installations were. This fixed Ubuntu and Windows XP, but Windows 7 (whether the original or the copy) would not boot. (Sometime around here I removed the old 7 drive from the machine which I believe to be failing.)

I tried all the usual shit. Various Grub configurations, various Windows boot configurations, moving around the boot flag, updating Grub at various moments. Bah! Nothing would improve matters if I chose 7: the basic black screen and quickly flashing cursor that meant the machine was waiting for an operating system to take over.

Using Grub to point to XP and then trying to use the Windows boot menu to choose between 7 and XP brought in a host of its own problems. Fuck it. I threw in the towel and rebuilt the 7 partition(s).

Now Windows 7 was working great but this of course broke my Grub again. So once again I went back in with chroot and updated Grub. This wasn’t enough, but while looking up the commands for doing this I noticed a utility called boot-repair. It can be downloaded as a stand-alone ISO or it can be used within Ubuntu.

If you run the Ubuntu Live CD you can simply run these two commands to install and run boot-repair:

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

You can read more about its usage here. I ran it with the normal settings (after perusing the Advanced options) and it fixed my boot problem. Now all three operating systems boot from the Grub menu.

This boot-repair has some pretty cool options (like selecting which boot option is default). Definitely worth adding to your toolbox.


One thought on “Repairing Grub after Windows Breaks It

  1. Hey James,

    I’m just asking in case you’ve run into this and have a fix off the top of your head. It’s not a huge issue, just annoying.

    I set up my laptop to boot Win 7 (came with) or a couple instances of Ubuntu a couple years ago. If I hibernate Ubuntu on shutdown GRUB picks up with the menu upon firing up. If I hibernate Win though, it skips GRUB and insists on going through the Win 7 sequence, which I then Shut Down to get to Linux. That or the trusty “when you don’t have the time” punch Power for 5 seconds.

    This might have been an annoyance I could live with, but when I was in Spain took a friend to buy an almost identical laptop and set him up the same way. No prob! Hibernating Windows doesn’t lock you out of Ubuntu. I think I set him up with GRUB2, and I think I updated GRUB, but it still does that. Any idea why?

    And yeah, you were right. Aside from Flight Simulator and, yes, I still use CS4 a lot, I spend by far the lion’s share of my time in Ubuntu : )

Leave a Reply

Your email address will not be published. Required fields are marked *