Long story short; I’ve got a laptop with Windows 7, Linux Mint and Ubuntu Linux on it. I installed Linux Mint last and got the grub2 menu at boot up which let me choose Windows or Ubuntu or Mint. All was well.
Then I decided that I was grown up enough to run Fedora linux instead of Ubuntu and so it was time to replace the latter with the former. That was no problem but for some reason or other (not presently known) the Fedora grub loader install didn’t detect any of the other OS’es in their respective partitions on the hard drive.
So what I had was a Fedora-only boot.
To fix this and get my Windows 7 and Mint installs back again I had to do the following:
- Understand that Fedora (13) uses “legacy grub” and not “grub2”
- Identify where the other partitions existed in “grub speak” and how to map from something like “/dev/sdaN” to “(hd0,M)…
- Edit GRUB file and be done with it
Step 1: the difference between legacy and 2.0
Legacy grub and grub2 are different. I had been using grub2 via my Mint 8 install (which is also what Ubuntu 9+ uses.) The most important two differences (and the only ones that mattered for me in my quest to restore normality) were these:
- Legacy grub enumerates partitions on a hard drive starting at 0, grub2 starts at 1. This threw me when I referred to my Mint (Ubuntu) grub2 parameters side by side with the (now active) Fedora legacy grub parameters. Just keep it in mind…
- Legacy grub has all it’s options in a file called “menu.lst” usually (probably always..?) stored in the /boot/grub folder, grub2 stores it’s options (and menu items) in a file called “grub.cfg” in that same folder.
Step 2: Identify where your other partitions are
In this case my Fedora install was the 1st logical partition in the 1st extended partition of my main hard drive. Extended partitions always start at 4 (i.e. the first extended partition is partition primary number 4 on a disk, see this excellent guide for more on this.)
Now, to map from your /dev/sdaN to a corresponding grub (hd0,M) you do the following:
if is Legacy Grub then M = N-1
M = N
So, in my case, the 1st Logical Partition in the 1st Extended Partition is /dev/sda5 = (hd0,4) in legacy grub speak but (hd0,5) in grub2 speak. (NOTE: the 1st Extended Partition itself was /dev/sda4, but it’s just a “container” so it isn’t bootable.)
To identify which sdN corresponds to what I used the DiskUtility because it gives a nice visual overview of your drive and all the info you need (it also shows you how things are physically laid out, which is nice.)
The windows 7 partition was further down (not in the extended area) on /dev/sda3 and hence was mapped directly to (hd0,2/3) in legacy/2 grub speak.
My Mint partition sat a bit higher up at /dev/sda8 = (hd0,7/8).
Step 3: Edit GRUB file and be done with it
Ok, this is all you need and now for the editing. Recall that I started out with this legacy GRUB menu.lst (after installing fedora over my old Ubuntu partition);
title Fedora (220.127.116.11-95.fc13.i686)
kernel /boot/vmlinuz-18.104.22.168-95.fc13.i686 ro root=UUID=6d1df250-76a4-4fe8-9afc-4d398a9b6eac rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us rhgb quiet
And so, armed with the correct (hd0,M)’s, added Mint and Windows like this:
title Linux Mint 8 Helena, linux 2.6.31-14-generic
kernel /boot/vmlinuz-2.6.31-14-generic ro root=UUID=a2d1515b-d544-4475-9f0d-a111e2b61e77 quiet splash
title Windows 7 (loader)
Btw, I’ve assumed you know how to specify the other GRUB parameters but quite frankly you can do this without understanding them completely… All I did (before I actually spent some time RTFM’ing) was to copy’n paste the entry from the Fedora install and just making the adjustments needed. The Windows7 entry seems to be standard for booting Windows (and perhaps Mac OS too, but I don’t know) and basically says “don’t try to figure out what it is, just load up and let go.”
One last word: how did I figure out the UUIDs for the partitions? Well, there’s many ways to skin this cat too but DiskUtility is the easiest because it presents the information when you click on a partition. Another option is to run “blkid” in the terminal (you don’t need to be su to do this) which lists all the drives and partitions in your system together with their UUIDs and file system types. Handy.
And that, as they say, was that.