Grub

From Nuclear Physics Group Documentation Pages
Revision as of 14:30, 17 January 2008 by Maurik (talk | contribs)
Jump to navigationJump to search

GRUB

It seems I will never really fully understand the details of how "grub" does it's stuff. This is more a quick reference, look at the real documentation for more.

Installing grub on a disk

Info: Grub Installation

To use grub you need to put the boot loader(s) onto the disk you plan to boot from. The system from which you are doing this MUST have the correct /dev/* devices. Sometimes (when using chroot say) this will not be the case. Here we put grub onto the main system disk. To use other disks, replace (hd0,0) with (hd?,0) and (hd0) with (hd?), where ? is the disk number. If you want to install grub on the partition rather then the master boot record, replace "setup (hd0)" with "setup (hd0,0)". Here are the commands:

>grub
# Look for partitions that have a grub directory.
grub> find /grub/stage1
(hd0,0)
(hd1,0)
(hd4,0)
...
grub> root (hd0,0)
grub> setup (hd0)

This will put grub on the first BIOS disk MBR (usually the one the BIOS tries to boot from). If you want to put it on the first partition of that drive instead, use "setup (hd0,0)" instead. Note that it MUST be either on the MBR or on the first partition, unless you are "chain-loading", which we never will be for Linux.

You can also use the script "grub-install" to install grub. This may not always work, depending on the details of the system you are working with:

grub-install /dev/sda
or
grub-install hd0

to put grub on the MBR of the first disk.

A note of caution. There is a file: /boot/grub/device.map that maps (hd?) to /dev/xxx. I am not sure if it is actually used or not!


A final, do it the brute force way, of installing grub is as follows (works for floppy!)

  1. cd /boot/grub
  2. dd if=stage1 of=/dev/fd0 bs=512 count=1

1+0 records in 1+0 records out

  1. dd if=stage2 of=/dev/fd0 bs=512 seek=1

153+1 records in 153+1 records out

The grub.conf file

All instruction for grub on what to do are in the file grub.conf, usually in /boot/grub.