Ubuntu – How to set up Grub properly to quad-boot Windows, Mac OS X, Linux, and FreeBSD


Grub has gone completely insane on me. My quad-boot system was working great up until I upgraded Ubuntu to 12.04. Since Ubuntu overwrote the Grub stuff I had to repair it with my Mac OS X and FreeBSD entries. After this, trying to boot Mac OS X gave me the error "couldn't open file" and FreeBSD gave the error "no such partition". Windows and Ubuntu worked fine.

So I tried repairing again because I figured something must've gone wrong in the install process. Then only Ubuntu would boot. Trying to boot Windows would give me the error "no argument specified".

I tried repairing Grub once again, since I seemed to be getting different results each time. This time, Ubuntu no longer appeared in the Grub menu, and the errors for the other OSes were the same.

So I booted into the Ubuntu 12.04 live CD and ran Boot-Repair with recommended settings. Now Grub is completely skipped and Windows boots up.

I have absolutely no idea what is going on or why I get different results every time I reinstall Grub. Here is how my partitions are set up:

  • sda1 – Storage drive,
  • sdb1 – Windows,
  • sdb2 – Mac OS X,
  • sdb3 – FreeBSD,
  • sdb4 – Extended,
  • sdb5 – Ubuntu,
  • sdb6 – Shared storage,
  • sdb7 – Shared Storage,

Here's my grub.cfg file: grub.cfg

Best Answer

Okay, it sounds like your GRUB installation was messed up, and then Boot Repair overwrote it with the Windows MBR.

Boot into the Ubuntu 12.04 LiveCD and reinstall Grub2 from the terminal. I'm presuming you aren't upgrading from some older Ubuntu that came with Grub Legacy. Either way, you want Grub2, which comes with Ubuntu by default.

These are commands you'll want to run, replacing /dev/sdAX with the partition that you have Ubuntu on (which appears to be /dev/sdb5 - you can check with 'sudo fdisk -l'):

sudo su
mkdir /mnt/root

mount -t ext4 /dev/sdaX /mnt/root
mount -t proc none /mnt/root/proc
mount -o bind /dev /mnt/root/dev
mount -o bind /sys /mnt/root/sys

chroot /mnt/root /bin/bash

sudo grub-install /dev/sda
sudo update-grub

Basically, it loads the necessary files from Ubuntu, then uses them to find all your OSes and setup a grub.cfg file.

Some more information on installing Grub2 here.

Related Question