How to install GRUB on the MBR

GRUB (GRand Unified Bootloader)

Briefly, a boot loader is the first software program that runs when a computer starts. It is responsible for loading and transferring control to an operating system kernel software (such as Linux). The kernel, in turn, initializes the rest of the operating system (e.g. a GNU system).

GNU GRUB Homepage
http://www.gnu.org/software/grub/

Problem

“There is not a boot manager screen at all, it just boots right into windows but GRUB boot window does not appear. I cannot figure out to access fedora, I do not have a boot disk and need to know if there is someway to boot into fedora”

“I forgot to install GRUB, I didn’t install GRUB in the MBR, I chose to install GRUB on the first track on the partition where I installed Fedora but that was not an active primary partition”.

Solution

You have to install GRUB on the MBR (Master Boot Record). To do this just follow this steps:

(First of all, enter your BIOS setup and in BOOT Sequence window choose to boot with CDROM first.)

1) Boot with your Fedora Core Installation CD 1.

2) Type “linux rescue” at the prompt.

3) Answer the questions about keyboard and language.

4) Tell the rescue mode to use your proper partition to mount (the one that you want to get booted into)

5) When you come to the console prompt type: chroot /mnt/sysimage

6) Type grub

7) Set the GRUB’s root device to the partition containing the boot directory like this:

grub> root (hd0,0)

Filesystem type is ext2fs, partition type 0x83

I have Windows 98 in hd0,0 ; Windows XP in hd0,1, Fedora Core /boot partition in hd0,2 and Mandrake /boot partition in hd0,6. So in my case the command should be: > root (hd0,2)

If you are not sure which partition actually holds this directory, use the command ‘find’ like this:

grub> find /boot/grub/stage1

This will search for the file name ‘/boot/grub/stage1’ and show the devices which contain the file.
Once you’ve set the root device correctly, run the command ‘setup’.

8) Then, run the command setup

grub> setup (hd0)

Checking if “/boot/grub/stage1” exists……. no
Checking if “/grub/stage1” exists……. yes
Checking if “/grub/stage2” exists……. yes
Checking if “/grub/e2fs_stage1_5” exists……. yes
Running “embed /grub/e2fs_stage1_5 (hd0)”……. 15 sectors are embedded
succeded
Running “install /grub/stage1 (hd0) (hd0) 1+15 p (hd0,2)/grub/stage2 /grub/grub.conf……. succeded
Done

This command will install GRUB boot loader on the Master Boot Record (MBR) of the first drive.

9) Type quit

grub> quit

GRUB is now in the MBR.

10) Finally, you’ll have to edit your /boot/grub/grub.conf, for example whith nano:

> nano /boot/grub/grub.conf

(/etc/grub.conf or /boot/grub/grub.conf or /boot/grub/menu.lst, they are the same file) This file has the boot partitions of the disk/s.

11) Restart your PC without the Fedora Core CD 1 Installation.

My grub.conf

default=0
timeout=30
splashimage=(hd0,2)/grub/splash.xpm.gz

title GNU/Linux Fedora Core 1 (2.4.22-1.2188.nptl)
root (hd0,2)
kernel /vmlinuz-2.4.22-1.2188.nptl ro root=LABEL=/ hdc=ide-scsi hdd=ide-scsi apm=off acpi=on vga=788
initrd /initrd-2.4.22-1.2188.nptl.img

#title GNU/Linux Fedora Core 1 (2.4.22-1.2174.nptl)
#root (hd0,2)
#kernel /vmlinuz-2.4.22-1.2174.nptl ro root=LABEL=/ hdc=ide-scsi apm=off acpi=on rhgb
#initrd /initrd-2.4.22-1.2174.nptl.img

title GNU/Linux Mandrake 9.2
kernel (hd0,6)/vmlinuz root=/dev/hda8 devfs=mount hdc=ide-scsi resume=/dev/hda9
initrd (hd0,6)/initrd.img

title Microsoft Windows 98 SE & XP Pro
rootnoverify (hd0,0)
chainloader +1

List of commands,

default=0
My default boot system is, of course, Fedora.

timeout=30
Fedora will boot in 30 seconds if you don’t touch anything.

splashimage=(hd0,2)/grub/splash.xpm.gz
Generally the splash image is in your /boot partition. In my case, hd0,2 is where I have the image.

title GNU/Linux Fedora Core 1 (2.4.22-1.2174.nptl)
The name of your OS that will appear in your menu at starup, you can write anything you want.

root (hd0,2)
This is your /boot partition specifies which partition contains your Linux kernel image. So “root (hd0,2) tells GRUB that the kernel is on the 3rd primary partition of my first hard disk (I have two), in my case (hd0,2).

kernel /vmlinuz-2.4.22-1.2174.nptl ro root=LABEL=/ hdc=ide-scsi apm=off acpi=on rhgb
Tells GRUB where to find your kernel, my kernel version is 2.4.22-1.2174, you have to type your kernel version.

rhgb
Red Hat Graphical Boot

apm=off acpi=on
I had to add ‘apm=off acpi=on’ to my kernel parameters to get power-off to work properly.

initrd /initrd-2.4.22-1.2174.nptl.img
Tells where your init ramdisk image is located.

title Microsoft Windows 98 SE & XP Pro
As I said, I have Windows 98 in hd0,0 and Windows XP in (hd0,1).

rootnoverify (hd0,0)
rootnoverify tells GRUB to boot from the Windows partition, but not to attempt to mount it.
(hd0,0) is where Windows XP puts the boot.ini to boot into Windows 98 and XP.

chainloader +1
chain-load is the mechanism for loading unsupported operating systems by loading another boot loader. It is typically used for loading DOS or Windows.
chainloader tells GRUB to chain to Windows’ boot loader which will start Windows.

Other options you can use:

map
If you have installed DOS (or Windows) on a non-first hard disk, you have to use the disk swapping technique, because that OS cannot boot from any disks but the first one.

Map the drive from_drive to the drive to_drive. This is necessary when you chain-load some operating systems, such as DOS, if such an OS resides at a non-first drive. Here is an example:

grub> map (hd0) (hd1)
grub> map (hd1) (hd0)

This performs a virtual swap between your first and second hard drive.

Caution: This is effective only if DOS (or Windows) uses BIOS to access the swapped disks. If that OS uses a special driver for the disks, this probably won’t work.

makeactive
Set the active partition on the root disk to GRUB’s root device. This command is limited to primary PC partitions on a hard disk.

Code:

title Windows 98 SE map (hd0) (hd1) map (hd1) (hd0) makeactive rootnoverify (hd1,0) chainloader +1

hide
Hide the partition partition by setting the hidden bit in its partition type code. This is useful only when booting DOS or Windows and multiple primary FAT partitions exist in one disk.

unhide
Unhide the partition partition by clearing the hidden bit in its partition type code. This is useful only when booting DOS or Windows and multiple primary partitions exist in one disk.

Explanation and examples of the hide and unhide commands

If you installed more than one set of DOS/Windows onto one disk, they could be confused if there are more than one primary partitions for DOS/Windows. There is a solution if you do want to do so. Use the partition hiding/unhiding technique.

If GRUB hides a DOS (or Windows) partition, DOS (or Windows) will ignore the partition. If GRUB unhides a DOS (or Windows) partition, DOS (or Windows) will detect the partition. Thus, if you have installed DOS (or Windows) on the first and the second partition of the first hard disk, and you want to boot the copy on the first partition.

Here’s how to create two installations of Windows, hda1 and hda2 or (hd0,0) and (hd0,1), using the commands hide and unhide.

For Windows 98 SE “My Entry”:

Code:

title My Entry unhide (hd0,0) hide (hd0,1) rootnoverify (hd0,0) makeactive chainloader +1

For Windows 98 SE “Family Entry”

Code:

title Family Entry unhide (hd0,1) hide (hd0,0) rootnoverify (hd0,1) makeactive chainloader +1

I did not have to use the ‘hide’ or ‘unhide’ command ’cause Windows XP, 2000 or NT have a boot manager (boot.ini) included. So, I only had to point where this boot.ini is. In my case, Windows XP copies this boot.ini where Windows 98 is installed, (hd0,0)
You should definitely use the ‘hide’ or ‘unhide’ command if you have,for example, two installations of Windows 98 or ME.

If everything went just fine, voila, GRUB now becomes your main boot manager for your multi OS system.

GRUB and Linux Partitions

First of all, GRUB requires that the device name be enclosed with ( ). Please, note that the partition numbers are counted from zero, not from one.

(hd0) in GRUB = is hda in Linux
Here, ‘hd’ means it is a hard disk drive. The first integer ‘0’ indicates the drive number, that is, the first hard disk.

(hd1) in GRUB = is hdb in Linux
The first integer ‘1’ indicates the drive number, that is, the second hard disk.

(hd0,1) in GRUB = is hda2 in Linux
This expression means the second primary partition of the first hard disk drive. In this case, GRUB uses one partition of the disk, instead of the whole disk.

(hd0,4) in GRUB = hda5 in Linux
This specifies the first extended partition of the first hard disk drive. Note that the partition numbers for extended partitions are counted from ‘4’, regardless of the actual number of primary partitions on your hard disk.

(hd0,5) in GRUB = hda6 in Linux
This is the first logical unit of the extended partition of the the first hard disk.

(hd1,0) in GRUB = is hdb1 in Linux
This is the first primary partition of the second hard disk.

Bir yanıt yazın