View Full Version : [SOLVED] Where is Grub?

14th September 2010, 02:53 PM
I'm (finally!) getting ready to install Fedora 13. However, back when I installed Fedora 12, I had just bought a used computer that had two physical disk drives. Windows XP was on drive 1, and drive2 was virtually empty. So at that time I reformatted drive 2 and installed F12 on it. I also used Grub as my boot loader and configured it to boot either XP or F12.

Now I'm ready to install F13, and I can't remember where I put Grub: on the MBR of drive 1 (called sda by F12) or the MBR of drive 2 (called sdb by F12). I think I installed Grub on sda, the physical drive that has XP on it.

(1) Is there a way I can determine where Grub is currently installed? I looked at grub.conf, but wasn't able to make the determination. (For one thing, the file refers to hd0 and hd1 when there are no files that start with "hd" on /dev. )

(2) Wherever it is now has worked fine. If it is on the MBR of sda (the XP disk), does anyone see any problems in doing it the same way when I install F13?

Thanks a lot.


14th September 2010, 03:42 PM
Your bios determines which drive is booted. If you are booting to a grub menu then you probably put grub on the MBR of that drive. On my box the bios configuration is accessed by pressing the delete key during initial startup (you may have to hold it down, things are happening pretty fast there) - if your bios uses a different key it should tell you somewhere onscreen during the initial system messages.

Look at the bios settings to see which drive is configured to boot, and the initial stage of grub is probably on the MBR of that drive.

Note that grub has several parts. Most of it is located under /boot.

15th September 2010, 10:19 AM
Grub has its own way of labelling drives and partitions as you noticed. For example, (hd0) is whichever drive is first in the order assigned by the BIOS, and (hd0,0) is the first partition on that drive. Have a look at "info grub" and the section "Naming convention" for full details.

I should say you would be fine keeping things as they are and installing 13. In any case, the installation process should give you the option to install a bootloader again.

16th September 2010, 06:40 PM
Thanks to all for the help.

I did successfully install F13 on the second drive /dev/sdb and put Grub on the MBR of the first drive /dev/sda, the Windows drive. Both Windows and Fedora are booting through Grub.

Now a new question: I want to install a different version of Windows on sda. I don't remember the ins and outs of installing Windows, but this will possibly overwrite Grub on the MBR.

(1) Is it possible to avoid this?

(2) If Grub is overwritten, how can I restore it after Windows is installed? Presumably, I won't be able to boot Fedora once Grub is overwritten.

I know that it probably would have been better to install the new Windows first before installing F13. However, the deed is done now, and I've spent a lot of time doing the immediate updates and getting everything working in F13 (as my other recent posts have indicated!). So I'd like to know if there is some way to do the install of Windows at this point without having to reinstall F13.


16th September 2010, 06:57 PM
You might install Microsoft and then boot from a liveCD/USB and do the /boot stuff from there.

mkfs.vfat /dev/sda1
and then run grub-install. I'm not sure if the live image will configure grub for your existing systems or not.

16th September 2010, 09:57 PM
Hi billquinn-
If I'm reading your post right, you installed grub on the MBR of sda, and the rest of fedora on sdb. And now you want to put a new version of windows on sda. Right?

I don't think you can prevent windows from overwriting the MBR of sda, but it isn't a big deal to recover from that. You'll need a fedora livecd or installation disk, or even the Super Grub Disk.

First, here's an overview of what is going on here. The part of grub that installs to the MBR is called Stage 1, and it is just a small amount of code and a pointer to the rest of grub. The bios runs the MBR code which follows the pointer to stage 2, which is the /boot/grub directory. In order for this to work, grub has to know where the rest of itself is installed when it writes the MBR.

So the first thing you need to know is, where is grub? (your original question :D) If you look at the grub.conf file, in the fedora entry, this will be called "root". It is probably "root (hd1,0)", in grub's terminology.

Make a note of that "root (hdx,y)", whatever the x and y are. And make sure you have either a fedora livecd, or an installation disk, or the Super Grub Disk. Then go ahead and install windows. When that completes, you need to either boot the fedora livecd, or the install disk in rescue mode.

Next, you need to start the grub shell by entering the command "grub" in a terminal, without the quotes. You should get a prompt that reads "grub>". Then you need to tell it where grub is located, by entering exactly what you noted down earlier: "root (hdx,y)" - that will probably be root (hd1,0). Hit <enter> and you should get the grub> prompt again. This time, enter "setup (hd0)". That will tell grub to write a new MBR on sda, pointing to the rest of grub on the first partition of the second drive.

That's it. Enter "quit" in the grub shell, exit the live cd or rescue disk, and you should be able to boot fedora.

17th September 2010, 09:45 AM
As a slightly paranoid addition to sonoran's excellent advice: I have usually physically removed the disk containing Fedora during the Windows installation process just to make sure!

Last time I donwloaded it, the RIPLinuX (http://www.tux.org/pub/people/kent-robotti/looplinux/rip) CD contained a useful script called backup-mbr which will allow you to make copies of the MBR (boot sector and partition table), which has saved my bacon more than once.

17th September 2010, 04:59 PM

Thanks so much for the detailed instructions. I had no problem following them, and they worked perfectly.


Thanks for the additional advice. I'll check out this RIPLinuX software. However, I didn't want to take out the disk drive, because I wanted the newly installed version of Windows to "recognize" my system the way it is. This is directly related to the reason I wanted to reintall XP in the first place. See my latest problem...

New Problem:

I had a computer with the two physical disk drives I described, sda (Windows XP installed) and sdb (Fedora 12 installed). Then I updated my hardware: new case, new Intel motherboard, new Intel CPU (dual core), and a new video card. The only thing that was to remain the same were the two disk drives--I simply put them into the new computer.

Naturally upon booting, F12 and Windows XP faced all new hardware. As one would expect, a superior OS like Linux had no problem. Windows however couldn't cope. It no long had sound and no longer could connect to the Internet through my router. However, this was not an urgent problem to fix. My production OS is Fedora. I need Windows for only one reason: to check my Web sites on that non-compliant piece of junk called Internet Explorer to see if everything I coded according to standards actually works on IE.

Next chapter in the story: it was time to install Fedora 13, which I did, as per several recent posts. Then I thought, well I should probably reinstall Windows. I suppose I could have fiddled to try to correct the problems, but I thought a reinstall would be simpler. This brings the story up to the present. The Windows XP that I had been using on sda was the "Professional," and I didn't have the install CD for it because it was already on the drive when I bought it used. However, I did have an install CD for XP "Home Edition." That's what I just now tried to install.

The installation ran into a problem. It got through the first stage to where you reboot the computer for setup to finish its job. Setup continued to chug along for a few minutes after the reboot. Then a progress bar opened that was labelled something like "installing devices." Then setup aborted with very vague messages as to what caused the problem and what to do about it.

I had to some work to do on my Web sites, so I used Sonoran's excellent instructions to get Fedora back up. I'm done with the work now, and here I sit. :(

Any ideas why Windows setup aborted? Could it be that my new hardware could not be handled by this older Microsoft OS? What might be the offending item? Any ideas for a workaround? Or do I actually have to give Bill Gates money and buy Windows 7?

Thanks so much for all this help.

18th September 2010, 06:34 AM
You're welcome - glad it worked. As for Windows, I'm afraid I can't help there, I don't use it.

19th September 2010, 08:31 AM
Glad Fedora is up and running for you.

As for Windows, I am no expert, but I've found in the past that changing the hardware is not always straightforward. Swapping disks in and out seems harmless; changing video card usually means the chore of having to reboot in safe mode, remove the old drivers, then reboot and install new drivers; changing motherboard seems to kill the OS. (This last one is deliberate for some versions of Windows, I believe.)

By comparison, as you noted, Fedora usually copes seamlessly with changes of hardware.

As an aside, would it work to install wine, and run IE that way?

Chilly Willy
19th September 2010, 11:22 PM
billquinn ...

W/O knowing what that error message was or being able to otherwise tell what was happening at the time I can only guess. But the FIRST thing I'd check is the disk to make sure it doesn't have fingerprints or scratches. I had a similar problem once & it turned out to be ONE SMUDGE about half way. It worked fine until it tried to read that spot. Cleaned it off & it worked fine. I had the same with one I burnt but that one ended up being a "coaster" (that happens when OTHERS have access to the disks)

As long as they weren't the RESTORE disks for a certain machine, your disks SHOULD have loaded. (& I assume they were not)

20th September 2010, 12:31 PM
Thanks everybody for all the help!

I traced down the Windows problem. Apparently my Windows XP Home Edition install CD was so old that it could not handle the dual core of my new Intel CPU and aborted halfway through the installation while "installing devices." I disabled dual core in the BIOS, and then XP installed with no further problems.