Grub

From Nuclear Physics Group Documentation Pages
Revision as of 15:05, 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

Note: None of these methods seem to work for a disk of a virtual machine, when you run these from the host (domain0) system

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 common error here is:

grub-install /dev/sdb
/dev/sdb does not have any corresponding BIOS drive.

To fix that, edit /boot/grub/device.map to add the drive (as in "(hd1) /dev/sdb"

A final, do it the brute force way, of installing grub is as follows: This works for floppy! It will garble your partion table!

# cd /boot/grub
# dd if=stage1 of=/dev/fd0 bs=512 count=1
1+0 records in
1+0 records out
# 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.