{January 25, 2015}   grub 2 and multiple hard drives

I recently set my home computer up to dual-boot, and it took far longer than it should have, so I thought I’d blog about one of the issues.

I’ve got two hard drives; windows is undisturbed on hda, and linux I installed on hdb. After jumping through some bizarre hoops to get the bios booting off hdb (wtf asus bios, why do you hate multiple hard drives), I discovered grub couldn’t boot windows. I could boot windows from hda just fine, so I knew the problem was with grub…

First problem: 90% of the information out there is still for grub 1, not grub 2. they’re almost completely different beasts, with different config locations (/boot/grub/menu.1st vs /etc/grub.d/), different config languages, and even different bloody partition numbering systems! Oh, and of the 10% that is for grub 2, 90% of that is for ubuntu, which has a few convenience scripts other distros lack.

I’ll condense what I learnt about that here:

  1. Most of the stuff in /etc/grub.d/ is fancy autodetection scripts that you don’t want to touch.
  2. What you do want to touch is /etc/grub.d/40_custom. leave the tail line intact, and treat the part below as your old menu.1st, but with the new config language (api reference and examples).
  3. Ubuntu’s update-grub is just grub2-mkconfig -o /boot/grub2/grub.cfg

Once I had my head wrapped around grub 2 enough to get a test menuentry up, the next question was, what is actually wrong with the autodetected windows entry? The error windows threw had no shortage of google results, but a lot were from mangled windows bootloaders, or 32 vs 64-bit issues. Most of the rest talked about mbr vs gpt, or legacy bios vs uefi, or secure boot; I was almost convinced one of these was the issue, despite them all being in the context of windows 8 (I’ve got windows 7), but I kept testing other things while I thought about it, and happily stumbled on the solution:

It turns out that while installing opensuse, I had let grub swap the order of the hard drives, and it was passing on this swap to windows, confusing the heck out of it. I converted some grub 1 advice to grub 2 syntax (hint: map is now drivemap) and windows happily booted up from grub. :)

I’m worried by what I learnt about UEFI and Secure Boot, though. Between bricking bugs and vendor lock-in, it sounds like things could get ugly next time I want a new computer. :(


et cetera