I just encountered Grub Error 13 and Grub Error 17 for seemingly no reason. I fixed the problem and thought I could save others undue headache by explaining my fix here.

The Setup

I have Ubuntu Linux installed on one hard drive that fdisk calls /dev/hda and Windows XP installed on a second hard drive called /dev/hdb. To Grub, the mapping is as follows:

  • /dev/hda1 = (hd0, 0)
  • /dev/hdb1 = (hd1, 0)

This works because my BIOS agrees on this mapping.

The Mistake

After shutting down my computer, I unplugged only my Linux drive, which both my BIOS and Grub agreed was the main/first/primary drive, hoping I would somehow still be able to boot into Windows even though Grub is on my Linux drive. Alas, that didn’t work and I got some kind of “Grub configuration error” screen without seeing my Grub boot menu. I figured “oh well, I’ll just plug my Linux drive back in and boot into Windows”.

I shut down my computer, plugged my Linux drive back in, and powered on the computer. The Grub boot menu loaded again, as expected. When I tried to boot into Windows, however, it gave me a Grub Error 13. This was weird, since I hadn’t done anything to the Grub configuration. Exiting back to the Grub boot menu, I tried to load Linux. No luck, but this time it gave me a Grub Error 17. I tried following my own tutorial about error 17, but fdisk reported that /dev/hda1 was a Linux partition, as it should. What was going on?

The Explanation

Reading on the Ubuntu Forums, mbwardle wrote the following:

The error usually happens because Linux and your BIOS detect your hard disks in different orders. GRUB tries to translate between the two using the device.map file in /boot/grub/device.map, which is automatically generated. Chances are, it guessed wrong.

In my case, I have three SATA hard disks.

My BIOS sees them as:

  • HDD1 - 80 GB - Windows
  • HDD2 - 80 GB - Linux
  • HDD3 - 250 GB - Media

Linux sees them as:

  • /dev/sda - 80 GB - Windows
  • /dev/sdb - 250 GB - Media
  • /dev/sdc - 80 GB - Linux

mbwardle

So your BIOS and Grub are not necessarily talking about the same thing. This was what happened in my case. When I unplugged the Linux drive (which Grub and my BIOS thought of as the first drive) and left only the Windows drive (which Grub and my BIOS thought of as the second drive), I was left with only the second drive, but my BIOS started thinking of that as the first drive since that was the only drive plugged in. Then when I plugged the Linux drive back in, it was thought of as the second drive. Just because my BIOS changed the order, though, doesn’t mean Grub did: it still thought of Linux as #1 and Windows as #2.

The Solution

I shut down my computer, unplugged the Windows drive (the one Grub thinks of as #2), and left the Linux drive (the one Grub thinks of as #1) plugged in. I started my computer, thus making my BIOS think of the Linux drive as #1 again. I was able to boot Linux just fine from the Grub boot screen, though of course Windows was inaccessible because the drive was unplugged.

I shut down my computer again, plugged the Windows drive back in, and kept the Linux drive plugged in too. I started my computer, and then the BIOS saw the Windows drive and began thinking of it as #2, just like Grub does. Now I can boot both Windows and Linux because, once again, Grub and my BIOS agree about what order the drives are in.