4.5. Setting GRUB.
Section contents:
4.5.1. Introduction.
The GRand Unified Bootloader (GRUB)
has all LILO features and more, unlike LILO, GRUB is not specific
for Linux it could deal with many other Unix systems and thats where the name
come from. GRUB configuration file is '/boot/grub/grub.conf' or '/boot/grub/menu.lst'
(make a symbolic link if you are not sure), the most important GRUP feature
is that it could mount and access to files
(on ext2,ext3,reiserfs,xfs,jfs,FAT and many more file system types)
so you don't need to run it each time you edit the file or install a kernel,
it could boot systems or pass options that it's not configured to boot
with an interactive BASH like prompt, it has an on line help, GRUB could be used
when there is a change with your disk 'master' and 'slave' flags.
When GRUB starts it display a text or graphical a pre-configured
menu of system to boot with a timer, use arrows then press ENTER to boot,
you could press 'e' (if allowed) on any item to edit it before booting,
press 'c' (if allowed, I won't say it again) to enter GRUB interactive prompt,
if there is lock on edit,command line or some items on the window, to open the lock,
press 'p' then type the GRUB password.
If GRUB fails to locate its configuration file, then GRUB
will show a BASH like prompt, press 'TAB' once or twice for auto-complete,
type 'help' followed by any command to get help about it.
GRUB device names is unified in all Unix systems, its NOT the same as Linux
nor any other Unix, devices are written between parenthesis '()',
the hard disk is 'hd' adn floppy is 'fd' followed by a number
starting from 0, if you want a specific partition add its number (counting from 0)
after comma ',', for example
'/dev/hda1' is '(hd0,0)'
and '/dev/hda5' will be '(hd0,4)',
the whole floppy is '/dev/fd0' is '(fd0)'.
4.5.2. Using GRUB.
There are two types of booting methods, first is used to boot with mono-boot
or unsupported operating systems like DOS,Windows, it just load another
boot loader (on the first sector of that partition of that OS)
and it's upto it to boot that system, using 'chainloader'
command for example 'chainloader (hd0,0)+1'
to load the first sector on the first partition of the first hard disk,
the number after '+' is the number of sectors (to load from the current position, 0 sector),
another example 'chainloader (fd0)+1' to boot the floppy
(there is no partitions on the floppy), well, after this it does not boot!
it just collect information and after all issue 'boot' command
to do the booting. The 'chainloader' could boot not only
boot sectors but also files, you could save the boot sector on a file
like 'bootsect.dos' on the first partition, to boot use
something like 'chainloader (hd0,0)/bootsect.dos' then 'boot',
this way GRUB could load LILO or another GRUB somewhere else.
Next method is for multiboot systems like Linux and other Unix systems,
we use 'kernel' command followed by kernel file location followed by arguments,
for example a kernel located on the first logical partition on '/dev/hda5'
in GRUB terminology it's '(hd0,4)' and the file name is
'/boot/vmlinuz' the command is 'kernel (hd0,4)/boot/vmlinuz',
You could pass argument to kernel after kernel file location, for example
'kernel (hd0,4)/boot/vmlinuz root=/dev/hda5 ro',
then (after kernel) if it need a initial RAM disk use 'initrd'
followed by it's compressed RAM disk image file, for example
'initrd (hd0,4)/boot/initrd.gz', now type 'boot'.
To save some typing, you could omit device, just specify a default device
with 'root' followed by the device to mount, for example:
root (hd0,4)
kernel /boot/vmlinuz root=/dev/hda5 ro
initrd /boot/initrd.gz
boot
for devices that could not be mounted with GRUB like NTFS (or just to save time as in FAT,
why mount it if we don't want to access file on it) we use 'rootnoverify'
command followed by the device, to boot Windows type something like:
rootnoverify (hd0,0)
chainloader +1
boot
Windows can only boot from partitions marked with bootable flag to be
sure , use 'makeactive' to set this flag, you should not pass
device, it's known from 'root' and 'rootnoverify',
the typical commands to boot Windows is something like:
rootnoverify (hd0,0)
makeactive
chainloader +1
boot
4.5.3. GRUB configuration file.
A sample GRUB configuration file:
# menu.1st: Sample boot menu configuration file for grub
# by Moayyad al-Sadi <alsadi[at]gmail.com>
# default item is number 0 item (1st one)
default=0
# if can't then try the 2nd one
fallback 1
# boot if nothing selected in 7sec
timeout=7
# do not allow grub console and editing
# unless password is given
password --md5 $1$ab0cdf.152467795
# for grapical mode
# a 640x480x16 compressed xpm image
splashimage=(hd0,4)/boot/grub/logo.xpm.gz
background 000080
foreground ffffff
shade 1
# set color to blue not needed in graphics
# color white/blue blink-yellow/magenta
title Linux
root (hd0,4)
kernel (hd0,4)/boot/vmlinuz ro root=/dev/hda5 hdd=ide-scsi
# you can give long titles
title Linux in text mode
root (hd0,4)
kernel (hd0,4)/boot/vmlinuz 2 ro root=/dev/hda5 hdd=ide-scsi
title Windowz (Bug mode)
# don't boot without password
lock
rootnoverify (hd0,0)
chainloader +1
makeactive
title floppy
# don't boot without password
lock
chainloader (fd0)+1
title Change console colors
color light-green/brown blink-red/blue
notice that we protected sensitive items with 'lock' command,
the password is specified with command 'password --md5' followed
by the enrypted password hash, you could copy it from '/etc/passwd' or '/etc/shadow'
or generate it using 'md5crypt' inside GRUB prompt,
or 'grub-md5-crypt' program.
The wallpaper is specified witth 'splashimage', which is a 16 color (4 bits) and '640x480'
gzipped XPM file, I think that it differs from distribution to another,
I tried GRUB 0.92 shipped with RedHat 8.0 and it's by default use graphical menu
with splash image, the same version shipped with Mandrake 9.0 but splash image
is not configured by defualt and it will be ignored if you add it,
GRUB shipped with Debian is not configured by defualt to show a splash image
but you may create one and it will work.
To install grub for the first time, type 'grub' to get GRUB prompt then
type: (only bold)
grub> root (hd0,4)
grub> setup (hd0)
with 'root' we tell it where to search for configuration file,
then we tell it where to install, here we specify MBR of frist disk
(because we did not specify partition) in other words '/dev/hda',
this should be done once (at least).
4.5.4. GRUB rescue boot floppy.
Get a floppy disk, remember data will be ERASED! then type
bash# cd /boot/grub
bash# dd if=stage1 of=/dev/fd0 bs=512 count=1
bash# dd if=stage2 of=/dev/fd0 bs=512 seek=1
or equivalently
bash# cd /boot/grub
bash# cat stage1 stage2 | dd of=/dev/fd0 bs=512
this bootable floppy will give you (when you boot from it) a GRUB
prompt where you could use commands we have learned to boot
your systems, it could load the boot menu (GRUB configuration file)
from the hard disk, it could mount partitions with 'root' and display
files with 'cat'.
|
Best viewed with free web browsers
You may get more high quality software
from here for free

Generously Hosted by www.JadMadi.net
|