
Invocation of the boot loader usually occurs in one of two ways:
The first stage boot loader is also known as Initial Program Loader (IPL). It must be less than 512 bytes in size, so it is fairly limited. It's primary job is to load a more functional boot loader (a.k.a. the second stage boot loader).
There are two different ways to configure a boot loader:
/etc/lilo.conf
Sample File:
prompt # Present lilo prompt so user can interact with lilo
timeout=50 # Timeout in milliseconds to wait for user interaction
default=linux # Default image to boot
boot=/dev/hda6 # Specifies boot device (Location to install primary boot loader)
# To install in the MBR, specify /dev/hda
map=/boot/map # Location of map file
install=/boot/boot.b # Location of Second stage boot loader
password=some_passwd # A password required to boot
restricted # Password only required if options are entered at boot prompt
message=/boot/message # Text message or splash screen (PCX) that will be displayed at boot time.
linear
# Image definition
image=/boot/vmlinuz-2.4.7-10 # Specifies location of the virtual memory compressed kernel
label=linux
initrd=/boot/initrd-2.4.7-10.img # Initial RAM Disk
read-only
root=/dev/hda9 # Location of root file system
other=/dev/hda1 # Image definition
optional
label=windows
See lilo.conf man page for an example.
-t - Test lilo configuration, but don't actually install.-v - Verbose
Command line options can be entered at the boot prompt by appending it to the image that you are booting. For example:
linux root=/dev/hda5 mem=128M 1
Tells lilo to boot the kernel with a label of "linux" into runlevel 1 using /dev/hda5 as the root filesystem. It also states the machine has 128 MB of RAM.
If lilo has been password protected, you will be required to enter the password before booting.
The 'LILO' prompt itself can be used to help diagnose boot related errors. The number of letters presented at the LILO prompt can indicate the success or failure of the boot loader.
L = First stage boot loaded and started. Usually indicates disk problems or invalid options in /etc/lilo.conf.
LI = Second stage boot loaded from /boot, but /etc/lilo.conf has invalid parameters or /boot/boot.b was moved without re-running /sbin/lilo.
LIL = Second stage loader started, but the descriptor table can't be loaded due to a bad disk or invalid parms in /etc/lilo.conf.
LIL? = Second stage loaded at an incorrect address because of invalid parms in /etc/lilo.conf or /boot/boot.b was moved without re-running /sbin/lilo.
LIL- = Descriptor table is corrupt. Caused by invalid parms in /etc/lilo.conf or /boot/boot.b was moved without re-running /sbin/lilo.
LILO = All of LILO loaded correctly.
/sbin/lilo every time you change your configuration.
Use lilo to fix:
/sbin/lilo
When LILO overwrites an existing boot sector, it saves a copy of the original boot sector
in /boot. The name of the original boot sector will be boot.MMmm where 'MM'
is the major device number and 'mm' is the minor device number. So, the original boot sector
from /dev/hda will be /boot/boot.0300.
To restore the original boot sector, use the dd command:
dd if=/boot/boot.0300 of=/dev/hda bs=446 count=1
The original boot sector is actually 512 bytes in length, but the remaining bytes after 446 are part of the partition table and we don't want to overwrite that in case it's changed.
mkinitrd /boot/initrd-2.4.7-10 2.4.7-10
/etc/lilo.conf file as shown above.
/boot/grub/grub.conf
Sample Configuration
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/hdb5
# initrd /initrd-version.img
#boot=/dev/hdb
default=0 # Default to First definition for booting
timeout=10 # Time in seconds to wait for user interaction
splashimage=(hd1,0)/grub/splash.xpm.gz # Splash Screen
password --md5 $1$ÈàíÂõXÛt$Z.............. # Password protection
title Red Hat Linux (2.4.17) # First definition
root (hd1,0)
kernel /vmlinuz-2.4.17 ro root=/dev/hdb5
title Red Hat Linux (2.4.17pre2-pk) # Second definition
root (hd1,0)
kernel /vmlinuz-2.4.17pre2-pk ro root=/dev/hdb5
title Red Hat Linux (2.4.17pre2)
root (hd1,0)
kernel /vmlinuz-2.4.17pre2 ro root=/dev/hdb5
title Windows 98SE
rootnoverify (hd0,0)
makeactive
chainloader +1
In order to pass arguments to the image being booted, you must enter menu editing mode, or enter the grub command line. If GRUB has been password protected, you'll need to enter 'p' followed by your password first.
To enter menu editing mode, select and entry and press 'e'. This will allow you to modify an existing boot setup and pass options to the kernel as well as init.
The GRUB command line allows you to create boot commands that don't exist in your grub.conf file. You can also run diagnostic tests and view the contents of files on your file systems.
(fd0) - First floppy drive detected by BIOS(hd0) - First hard drive detected by BIOS (SCSI or IDE)(hd1,3) - Fourth partition on the 2nd hard drive detected by the BIOS
Use grub-install to fix:
/sbin/grub-install /dev/hda
In this situation, we have a nameless OS installed on /dev/hda and Linux installed on /dev/hdb. We need to setup grub to boot both OSes. This involves installing the first stage of grub on the MBR of /dev/hda and the second stage of grub on the /boot partition of /dev/hdb. We will use the grub configuration file listed above. This scenario assumes you either have a working system or are running in rescue mode chroot'd to /mnt/sysimage.
/sbin/grub
Note: The remaining steps will performed from within the "grub shell".
root (hd0,0)
install (hd1,0)/grub/stage1 (hd0) (hd1,0)/grub/stage2 p (hd1,0)/grub/grub.conf
The above command line can be broken down as follows:
install <stage-1> <install-disk> <stage-2> p <config file>
| ERROR!! |