FedoraForum.org - Fedora Support Forums and Community
Page 1 of 5 1 2 3 ... LastLast
Results 1 to 15 of 66
  1. #1
    Join Date
    Feb 2004
    Location
    Buenos Aires, ARG
    Age
    41
    Posts
    320

    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.


    Related HOWTO
    How to edit your grub.conf
    http://www.fedoraforum.org/forum/sho...=&threadid=996

    Good Luck !
    Last edited by gonzalo76; 3rd May 2004 at 06:39 AM.
    Greetings :)
    gonzalo

  2. #2
    Ug's Avatar
    Ug is offline Retired Community Manager
    Join Date
    Feb 2004
    Location
    London
    Posts
    2,999
    Very comphrensive!

  3. #3
    Join Date
    Feb 2004
    Location
    Buenos Aires, ARG
    Age
    41
    Posts
    320
    GRUB images files

    GRUB consists of several images: two essential stages, optional stages called Stage 1.5, and two network boot images. Here is a short overwiew of them.

    'stage1' This is an essential image used for booting up GRUB. Usually, this is embedded in an MBR or the boot sector of a partition. Because a PC boot sector is 512 bytes, the size of this image is exactly 512 bytes. All 'stage1' must do is to load Stage 2 of Stage 1.5 from a local disk. Because of the size restriction, 'stage1' encodes the location of Stage 2 (or Stage 1.5) in a block list format, so it never understand any filesystem structure.

    'stage2' This is the core image of GRUB. It does everything but booting up itself. Usually, this is put in a filesystem, but that is not required.

    'e2fs_stage1_5'
    'fat_stage1_5'
    'ffs_stage1_5'
    'jfs_stage1_5'
    'minix_stage1.5'
    'reiserfs_stage1.5'
    'vstafs_stage1.5'
    'xfs_stage1_5'
    These are called Stage 1.5 because they serve as a bridge between 'stage1' and 'stage2', that is to say, Stage 1.5 is loaded by Stage 1 and Stage 1.5 loads Stage 2. The difference between 'stage1' and '*_stage1_5' is that the former doesn't understand any filesystem while the latter understands one filesystem (e.g. 'e2fs_stage1_5' understands ext2fs). So you can move to Stage 2 image to another location safely, even after GRUB has been installed.
    While Stage 2 cannot generally be embedded in a fixed area as the size is so large, Stage 1.5 can be installed into the area right after and MBR, or the boot loader area of a ReiserFS or a FFS.

    'nbgrub' This is a network boot image for the Network Image Proposal used by some network boot loader, such as Etherboot. This is mostly the same as Stage2 but is also sets up a network and loads a configuration file from the netwrok.

    'pxegrub' This is another network boot image for the Preboot Execution Environment used by several Netboot ROMs. This is identical to 'nbgrub', except fro the format.


    Creating a GRUB boot floppy

    To create a GRUB boot floppy, you need to take the files 'stage1' and 'stage2' from the image directory, and write them to the first and second block of the floppy disk, respectively:
    Caution: This procedure will destroy any date currently stored on the floppy. On a UNIX-like operationg system, that is one with the following commands:
    Open a Terminal, become root with 'su' command and type:

    Code:
    cd /usr/share/grub/i386-redhat
    dd if=stage1 of=/dev/fd0 bs=512 count=1
    dd if=stage2 of=/dev/fd0 bs=512 seek=1
    Installing GRUB on a floppy disk
    Code:
    # /sbin/grub-install /dev/fd0
    # /sbin/grub-install /dev/fd0
    Installation finished. No error reported.
    This is the contents of the device map /boot/grub/device.map.
    Check if this is correct or not. If any of the lines is incorrect,
    fix it and re-run the script `grub-install'.

    # this device map was generated by anaconda
    (fd0) /dev/fd0
    (hd0) /dev/hda
    Everytime you install a new kernel you'll need to update your floppy disk running "/sbin/grub-install /dev/fd0" again.
    Last edited by gonzalo76; 16th February 2005 at 02:30 AM.
    Greetings :)
    gonzalo

  4. #4
    Join Date
    Jul 2004
    Posts
    1

    Bravo!!!!!!!!!!!!

    WOW. This how to is so clear! Way better then the Grub manual! Finally solved my problem. Not an easy task with all the misinformation and unclear directions (for a linux newbie) on the net.

    Other instructions say to edit the grub.conf file. No problem, where the heck is it? And what do I use to edit it at a command line? Every other instruction and suggestion I found assumed I knew a good bit about linux. Pretty silly, since most people looking for such help probably don't know much about linux.

    This how to answered all my questions and didn't produce 5 more for each answered questions.

    I simply cannot praise this enough. And cuss the writers of the other how-tos!

  5. #5
    Join Date
    Feb 2004
    Location
    Buenos Aires, ARG
    Age
    41
    Posts
    320
    Hi gmac0518, thank you for your reply.

    Im glad that my mini howto helped you !!!
    Greetings :)
    gonzalo

  6. #6
    Join Date
    Mar 2004
    Location
    Amerika
    Posts
    7
    Great info Gonzalo. I haven't needed it yet but have saved both posts for future "snarls." If you aren't already employed as a tech writer, you should give consideration to taking on the task of writing a HowTo book, etc.

    I also am envious since you are located in a city where you can follow Orquesta Contratiempo in person!

    Bandoneon forever!

  7. #7
    Join Date
    Apr 2004
    Location
    Slovenia
    Age
    34
    Posts
    1,713
    Really good how-to. I'm impressed.
    _ghaefb


    blog & sysinfo

  8. #8
    Join Date
    Feb 2004
    Location
    Buenos Aires, ARG
    Age
    41
    Posts
    320
    Thank you kondor and ghaefb for your nice comments.
    Greetings :)
    gonzalo

  9. #9
    Join Date
    Feb 2004
    Age
    49
    Posts
    8,255
    nice to see you back gonzalo....hey are also helping moderate in chile linux page?

  10. #10
    Join Date
    Sep 2004
    Location
    Milan
    Age
    33
    Posts
    1
    I had a similar problem but even if I followed all the steps you were suggesting I wasn't able to solve it. My problem is that in the eight stage it doesn't say me
    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


    but

    Checking if "/boot/grub/stage1" exists....... yes
    Checking if "/boot/grub/stage2" exists....... yes
    Checking if "/boot/grub/e2fs_stage1_5" exists....... yes
    Running "embed /boot/grub/e2fs_stage1_5 (hd0)"....... 15 sectors are embedded
    succeded
    Running "install /boot/grub/stage1 (hd0) (hd0) 1+15 p (hd0,6)/boot/grub/stage2 /boot/grub/grub.conf....... failed
    Error 12: Invalid device requested
    Done


    How can I solve it? Find /boot/grub/stage1 returns to me the value (hd0,6)
    Thanks in advance for the help
    I'm a newbie and help will be really appreciated

  11. #11
    Join Date
    Sep 2004
    Posts
    18
    This did not help me. All of the commands that you told me to do in grub did not work. It kept giving me unrecognized string errors; I don't think I have a /boot partition, though I thought I made one when I set up FC3. How can I do this now?

  12. #12
    Join Date
    Feb 2004
    Age
    49
    Posts
    8,255
    Quote Originally Posted by j0e
    This did not help me. All of the commands that you told me to do in grub did not work. It kept giving me unrecognized string errors; I don't think I have a /boot partition, though I thought I made one when I set up FC3. How can I do this now?
    what are you trying to do? can you be more specific?

  13. #13
    Join Date
    Jun 2004
    Location
    Germany-NRW
    Age
    35
    Posts
    69

    Works for FC2 too...

    Hey Gonzalo,
    Very good Tutorial!!
    But if you want to find the Partition containing the Boot Directory under FC2
    you have to type:
    Code:
    grub>find /grub/stage1
    NOT
    Code:
    grub>find /boot/grub/stage1
    All the other steps worked exactly the way you wrote in your Tutorial

    Greetings
    El Greco

  14. #14
    Join Date
    Aug 2004
    Posts
    93
    Excellent! Very good help in many aspects of GRUB.

    However, I'm having one small problem. My setup isn't addressed here (I didn't really expect it to be). It's an odd one, but I hope I can get it working. My Windows partition is /dev/sda1. How do I get GRUB to see that? Right now it's set up to load from (hd0,0), and I get a 'NTLDR not found' problem. But if I try to boot from anywhere else, GRUB'll tell me that the command was wrong or the partition wasn't there or something like that...

    So GRUB is on the MBR of /dev/hda, where Linux also resides. Windows is on /dev/sda. How do I make it all work?

  15. #15
    Join Date
    Nov 2004
    Location
    So Paulo, Brazil
    Age
    47
    Posts
    112
    Great job, gonzalo76!!!

    As gmac0518 has said, your tip is even better than the official grub manual. I've lost so much time searching for help around this issue that I will keep your text in a safe place. It's the better help I've found. Thanks!!!

Page 1 of 5 1 2 3 ... LastLast

Similar Threads

  1. GRUB: grub-install not working
    By greno in forum Using Fedora
    Replies: 5
    Last Post: 27th May 2009, 01:04 PM
  2. GRUB Raid0 & Install "grub hard disk error"
    By synic in forum Installation, Upgrades and Live Media
    Replies: 7
    Last Post: 24th February 2008, 11:45 AM
  3. Fresh Install - Install Updates - Now 2 versions in GRUB?? HELP
    By ViolentA79 in forum Installation, Upgrades and Live Media
    Replies: 7
    Last Post: 8th February 2008, 04:22 PM
  4. How to install GRUB without GRUB installed :P
    By jigarzon in forum Using Fedora
    Replies: 1
    Last Post: 16th February 2006, 10:43 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •