Bootloader Phase
The bootloader is software that the BIOS can load from the MBR of the hard that will allow the CPU to access the disk and load the operating system into RAM. The do this, the bootloader is configured with the location of the operating system files on the hard disk drive.
After loading the bootloader software into memory, the BIOS turns control of the ystem over to the bootloader.
With later Linux kernels, the bootloader may also create a temporary, virtual file system in your system RAM called a ramdisk. This file system is called initrd image.
The term "initrd" stands for initial ramdisk.
This image contains a basic file system that can be used to complete a variety of startup taks. The reason the initrd iamge is used is because Linux systems can use a wide variety of devices for the root (/) file system.
Kernal Phase
After the kernel loads, several key things happen, including the following:
- The kernel initializes the basic hardware in your system using the various settings in your BIOS and your CMOS chips.
- The kernel searches for and uses the initrd file system to run the linuxrc program to set up the system.
- When linuxrc has finished executing, the initrd file system is dismounted and the ramdisk is destroyed.
- The kernel probes for new hardware and loads the appropriate driver modules.
- The real root (/) file is mounted.
- The kernel loads the init process.
Lilo Bootloader
- Most current Linux distributions use the GRUB bootloader instead of LILO by default.*
The bootloader configuration file for LILO is found in /etc/lilo.conf
The following are options in the configuration file:
|
Section |
Option |
Description |
|
Global Options |
menu -scheme |
Describes the colors used in the LILO boot menu. The system is: Text_color:highlight_color:border_color:title_color You use 2 values for each section. The first is the forground color and the second is the background color. |
|
|
Timeout |
Sets the timeout period in 1/10th seconds before the default menu item is automatically run. The default is usually 80 which gives the user 8 seconds to select a menu item. |
|
|
Lba32 |
Tells lilo to ignore the hard drive's physical geometry and use logical block addressing. This allows LILO to work with disks that have more than 1023 cylinders (which all modern hard drive do). |
|
|
Change-rules |
Defines boot-time changes to partition type numbers. |
|
|
Reset |
Specifies that all default change-rules are removed. |
|
|
Read-only |
Specifies that the rool (/) file system be mounted read-only at first. After checking the integrity of the file system, the kernel will usually remount the file system in read-write mode. |
|
|
Prompt |
Specifies that the boot: prompt be displayed. |
|
|
Default |
Specifies the default image that will be loaded if the user doesn't make a selection. |
|
|
Message |
Specifies the location of the image file that LILO will display. |
|
|
Boot |
Specifies the device that contains the boot sector. |
|
Image Options |
Image |
Specifies the path to the boot image of a Linux kernel. |
|
|
Label |
Specifies a name for the image. |
|
|
Append |
Appends the specified options to the parameters that are passed to the kernel by LILO. This is ually only used if the system uses hardware the kernel is having a difficult time auto-detecting. |
|
|
Vga |
Specifies the VGA text mode that should be used while the system is booting. |
|
|
Initrd |
Specifies the initial ramdisk image to be loaded with the kernel. |
|
|
Root |
Specifies the device that should be mounted as root. |
You must type lilo in
the command prompt after making changes.
Grub Bootloader (
Grand Unified Bootloader)
Grub is separated in chunks called stages. These include the following:
- Stage 1 - This stage of GRUB is usually stored in the MBR. Its only real job is to point to the location of Stage 2.
- Stage 2 - This stage of GRUB is stored in a disk partition. When loaded by Stage 1, Stage 2 presents a graphical menu on the screen that allows the user to select the kernel image that should be loaded. Like LILO, you can configure GRUB with a default image and a timeout value. If the user doesn't select an option within the timeout period, the system will automatically boot the default kernel image.
Like LILO, it's also
possible to install Stage 1 in the boot partition. In addition, there may
actually be a GRUB stage 1.5 on some deployments. Stage 1 can either load Stage
2 directly, or it may point to stage 1.5, which resides in the first 30kb after
the MBR of the hard disk. Stage 1.5 then loads Stage 2.
To initially install grub you would enter grub-install device. The device would be the device whose MBR you want to install stage 1 into. Example: grub-install /dev/had
Grub references disks differently then LILO. The following is GRUB:
Hddrive_number,partition_number
GRUB Configuration File Option:
|
Section |
Option |
Description |
|
Global |
Color |
Specifies the colors to be used in the GRUB menu. |
|
|
Default |
Specifies the menu item that will be booted automatically if the user doesn't make a manual selection. |
|
|
Timeout |
Specifies the number of seconds to wait until the default menu item is automatically booted. |
|
|
Gfxmenu |
Specifies the location of the image file that will be used to display the graphical GRUB boot menu. |
|
Title |
Title |
Specifies the title of the menu item in the GRUB boot menu. |
|
|
Root |
Specifies the location of the partition that is to be mounted as the GRUB root. |
|
|
Kernel |
Specifies the location of the Linux kernel. |
|
|
Initrd |
Specifies the initrd image that should be used by GRUB to create the initial ramdisk image during boot. |
Runlevels
|
Runlevel |
Description |
|
0 |
Halts the system |
|
1 |
Runs Linux in single-user mode. The command-line interface is used. |
|
2 |
Runs Linux in multi-user mode with networking disabled. The command-line interface is used. |
|
3 |
Runs Linux in multi-user mode with networking enabled. The command-line interface is used. |
|
4 |
Unused |
|
5 |
Runs Linux in multi-user mode with networking enabled. The graphical user interface is used. |
|
6 |
Reboot |
The syntax for
commands within the inittab file is identifier:runlevel:action:command. The wait action specified in these commands tells the init process to
wait until the scripts for the specified runlevel have finished running before
moving on.
[ init completes the following tasks as it initializes a BSD-type system ]
- Runs the /etc/init.d/boot script to prepare the system.
- Processes /etc/inittab to determine the appropriate runlevel and scripts.
- Runs the scripts in the appropriate runlevel directory in /etc/init.d.
- Runs the /etc/init.d/boot.local script.
[ init completes the following taks on a V-type system ]
- Runs the /etc/rc.d/sysinit script to prepare the system
- Processes /etc/inittab to determine the appropriate runlevel and scripts.
- Runs the scripts in the appropriate runlevel directory in /etc/rc.d/.
- Runs the /etc/rc.d/rc.local script.
Important Files in
/etc/init.d
|
File |
Init Style |
Function |
|
Rc |
BSD and System V |
This script is used to switch between runlevels while the system is running. |
|
Halt |
BSD |
This script can stop or reboot your system. It is run if the current runlevel is changed to 0 or 6. |
|
Boot |
BSD |
This script is run by init when the system first starts. It runs the scripts contained in /etc/init.d/boot.d. These scripts accomplish a variety of startup tasks, such as loading kernel modules, verifying the file systems, and setting the system clock. |
|
Boot.local |
BSD |
This script is also run by init at startup. It contains additional startup commands. This script is extremely useful. If you want to run a particular command automatically at startup, you can insert the command into this file with a text editor. |
|
Rc.sysinit |
System V |
This script's function is similar to the boot script on a BSD-type system. It's used to set the path, check the file system for errors, set the system clock, etc. |
|
Rc.local |
System V |
This script's function is similar to that of the boot.local script on a BSD-type system. You can add your own commands to this script to ensure they are run every time the system boots. |
You can change runlevels by typing init runlevel example: init 3
If you look inside an
rcx.d directory within your distribution's init directory, you will see two
scripts for each system process. One starts with an "S" and one starts with a
"K". The scripts that start with S are used to start a process while the
scripts that start with "K" are used to kill a process. These are the scripts
employed when switching between runlevels on the fly as just described.
chkconfig - updates and queries runlevel information for system services
SYNOPSIS
chkconfig --list [name]
chkconfig --add name
chkconfig --
chkconfig [--level levels] name <on|off|reset>
chkconfig [--level levels] name
Leave a comment