Jeff Duntemann's Contrapositive Diary Rotating Header Image

Restoring Grub with Rescatux

If a task has to be done often enough, sooner or later somebody will automate it. And so it happened with a very common task that I’m glad I didn’t have to do the hard way: Restore Grub to the MBR after a Windows reinstall overwrote it.

Windows does not play nice with Linux the way Linux plays nice with Windows. When you install Linux on a hard drive that already contains a bootable Windows partition, Linux adds the Windows instance to the Grub bootloader menu, allowing you to choose which OS to boot on startup. On the other hand, when you install Windows to a hard drive that already contains a bootable Linux partition, Windows ignores the Linux partition and puts its own bootloader link into the master boot record (MBR.) At startup, the system boots straight into Windows. Linux is still there, but you don’t get to choose to boot into it at startup.

Getting Grub back into the MBR after a Windows reinstall isn’t hideously difficult, but it’s a bit of picky terminal work done from a LiveCD. The trick is knowing how. The canonical description of how to do it is borderline incoherent, including advice like “This method apparently no longer works. Use with caution (if at all.)” The information is all there, but you have to dig a little to make sense of it. (Being a Linux geek helps a great deal.)

There’s now an easier way that I wasn’t aware of the last time I had to reinstall Windows on a dual-boot system: The Rescatux LiveCD. It’s a Debian instance with some scripting added that puts up a wizard and automatically detects installed bootable partitions. It then rebuilds the Grub bootloader menu and points the MBR back to Grub.

A couple of cautions:

  • The wizard is fairly terse. Don’t expect a great deal of handholding. If you don’t have any prior experience with Grub, read the documentation on the Web site. Then read it again.
  • Give the wizard time to work at each step. When you click the OK button, the options reappear immediately, but when there’s some disk access to be done, the script goes off to work and doesn’t give you any indication that it’s working. It doesn’t take more than a few seconds. Be patient.

I failed to be patient the first time I ran Rescatux, and clicked something once too often. (I’m still not entirely sure what.) When I booted the system again, Grub ran and Ubuntu was listed, but this time Windows was missing. There’s some rough justice in that, I guess, but I need to get into Windows just as surely as I need to get into Ubuntu. So I rebooted back into Rescatux and ran the wizard again, giving it enough time to finish each step. Another reboot, and Windows was back in the Grub bootloader menu.

Supposedly Rescatux works with both Grub 2 (the current version) and “Legacy Grub,” V0.97. My system uses Grub 2, and thus I didn’t test its dealings with older Grub versions.

It’s still a little rough, but it saved me a certain amount of eye-crossing terminal work this afternoon, and that’s always a good thing. Be careful and read the doc before you begin, but having said that, I do recommend it.


  1. Erbo says:

    This is why, when I configured my workstation, I sidestepped the problem entirely by installing two physical hard drives, one for Linux, one for Windows. After installing Ubuntu to the first hard drive, I disconnected it and installed Windows to what was now the “first” drive, letting it party on that drive (to use the Microsoft terminology). Then I reconnected the Ubuntu drive (setting it as first in boot order, with the Windows drive second) and updated GRUB, which picked up the Windows install on the now-second hard drive. Windows boots normally, making its system partition the C: drive despite being on the second physical spindle.

    In practice, I now have three drives in that system, with the third disk partitioned into “data” areas for both Linux and Windows, so a failure on one of the system disks won’t eat personal files.

    1. That’s a really fine idea, and although it wouldn’t work for the SX280 (only one internal drive slot) it would certainly work on my Core 2 Quad. I’m not sure if I have still a free SATA port on the mobo, but if I do it’s worth a try. I don’t like the case I currently have and may rebuild the machine in another case, but that means I have to find a case that I like, which has always been a gnarly business.

      1. Erbo says:

        When I revamped my desktop from “Sangruse” to “Protea,” I got an ASUS M4A79XTD EVO motherboard, which has 7 SATA ports (and one eSATA port on the back panel), or plenty for that purpose. It’s a great mobo if you go the AMD route; I paired it with a Phenom II X4, but you could go the X6 route for hex-core goodness.

        Eventually I intend to move to more RAID-1 mirroring, especially on our “server” boxes here, as drives are fairly cheap these days and Linux will do good RAID-1 in software. My experience with the EMinds server has shown that RAID-1 can save your butt.

  2. Tom Dison says:

    Downloaded, added to my toolbox. I remember back in my Mandrake/Mandriva times, I could just pop in the install CD, which had a restore boot menu option when you booted it up.

    1. Never did a Mandriva install here, but that’s actually a damned fine idea too. I confess I’m not delighted with the way Canonical is taking Ubuntu (I dislike Unity for desktop use) and may consider something else post-Natty.

  3. Evert Mouw says:

    Thanks! I once spend too much time repairing grub-legacy (my own fault; use with ext4 was not supported) so maybe I’ll try this one next time.

  4. […] That set me off on a journey to get Fedora 14 working and running properly on the new laptop. Along the way, I dealt with boot and grub.conf issues for the first time. I was banging my head against the wall as I couldn’t restore my laptop back to its original factory state, and didn’t have a Windows XP CD handy. The Lenovo drivers on their site were of no help either as it was on Linux. Also had trouble getting the wireless card to jive with Linux once I was re-installing Fedora. Learned a lot about MBR and rescuing Grub with Rescatux. […]

  5. Alberto Guaba says:


    Hey guys can I get some help from you? This is my concern: I try to install Linux mint 13 mate in an external hard drive, trying to avoid problems with my windows 7. By the way I have a Sony Vaio Laptop and this is the model number, in case it might be useful for assessing the problem, VGN-NW320F. The thing is that after installing it and restarting my computer to boot from the EHD I just keep on getting this message: error: unknown filesystem —— grubrescue>_, and I don’t know what to do next. I have try to look for some infromation in the internet but since I don’t know much about computers I seem not to understand anything.

    Could you pls give me some help in very simple layman’s terms, I would really appreciate it. Thank you in advance.

Leave a Reply

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