Difference between revisions of "Grub"

From Nuclear Physics Group Documentation Pages
Jump to navigationJump to search
 
Line 5: Line 5:
 
== Installing grub on a disk ==
 
== Installing grub on a disk ==
  
To use grub you need to put the boot loader(s) onto the disk you plan to boot from. The following magic will do this:
+
Info: [http://www.linuxselfhelp.com/gnu/grub/html_chapter/grub_3.html Grub Installation]
  
  grub
+
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
  grub> root (hd0)
+
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)
 
  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".
+
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:
 
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:
Line 21: Line 32:
 
to put grub on the MBR of the first disk.
 
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!)
 +
 +
# 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 ==
 
== The grub.conf file ==
  
 
All instruction for grub on what to do are in the file grub.conf, usually in /boot/grub.
 
All instruction for grub on what to do are in the file grub.conf, usually in /boot/grub.

Revision as of 14:30, 17 January 2008

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.