Originally Published: Tuesday, 4 September 2001 Author: Siddharth Khosla
Published to: learn_articles_firststep/General Page: 1/1 - [Std View]

The Linux Boot Process on the i386

Take another look at exactly what happens to your system during the boot process. Understanding the boot process is critical to understanding good useage and administration practices.

What is Booting?

Before getting into the technicalities of the Linux boot process we should have a clear understanding of what exactly a "boot process" is. Whenever we switch on our computer or restart it, the whole process that results in your OS being loaded in its entirety comprises the boot process.

The BIOS

As soon as the computer is switched on control passes to the BIOS (The Basic Input Output System) which is present at the end of the read-only system memory. It can be said to be the lowest level interface between the computer and its peripherals. Once given control the BIOS checks all peripherals and does a few system checks. It then looks for a drive to boot from. The hierarchy of booting is customizable in the BIOS by running its setup. Usually it looks for someting to boot from in the floppy drive first and then from the cdrom drive. If no booting images are found in these peripherals it tries booting from the local hard drives. On the hard drive it looks for the MBR (Master Boot Record) in the first sector of the first hard drive (the primary master in most cases).

The MBR then looks for the first active partition in the drive. This active partition contains in its initial sectors what is known as a boot record. This boot record contains instructions on how to load the Boot Loader, which is a program used to load the particular OS. For Linux the boot loader is called the LInux LOader or LILO for short. As soon as the BIOS finds the LILO it runs it and control is passed on to the LILO.

THE LILO

Upon its initialization the LILO issues a prompt which asks the user for the label of the OS to which you want to boot. It also has a timeout specified upon the expiration of which the default OS specified is booted.

All these parameters: the timeout time, the OS labels, the default OS to boot and the type of disk etc are specified in a file called the LILO.conf. Thus for any changes to the LILO the lilo.conf file has to be changed. Now as we are looking into the linux boot process we consider that LILO starts to boot Linux. On booting Linux the first thing that LILO does is look for the boot kernel of Linux which is a file by the name of vmlinuz-22.15 ...and some version number. This file is found in the /boot directory. When vmlinuz is found LILO's role in the boot process ends and control is passed to the kernel.

The vmlinuz-22.15 kernel

The kernel is a program that controls the allocation and usage of the resources available to the operating system and divides them among its users. The very first thing that the linux kernel does is look for the init file which may be found in the /sbin directory. But the kernel does not limit its search in this directory but searches the whole partition and runs the first init it finds. When init is initialized by the kernel it becomes the first process of the kernel to run and thus is often referred to as the grandparent of all processes. From here on the control is passed on to INIT

INIT

The grandparent of all processes, init, can be said to be the root of the tree of processes which are run during Linux booting. Init runs a number of files during boot up. Some of the files it runs and their utility are given below :

/etc/rc.d/rc.sysinit

This is the first file that init runs. It is responsible for system initialization processes like setting paths, swapping memory, checking file systems. It also starts up getty processes like those required to log in , ftp daemons, httpdaemons, mail daemons, NFS etc. The init configuration files are found in the /etc/rc.d directory and the files there include :



1.init.d
2.rc0.d
3.rc1.d
4.rc2.d
5.rc3.d
6.rc4.d
7.rc5.d
8.rc6.d

The init.d directory contains the scripts to run at various runlevels. The rc.d directories contain the configurations for various runlevels. The implementation of rc.serial may also take place here if there is a need of a serial port. After the successful implementation of these files the /etc/inittab is implemented.

/etc/inittab

This file describes the way the system should be setup at different runlevels. It also specifies the default runlevels. The question that may come to your mind now might be,"what the heck is a runlevel?"

Linux has in all six runlevels which are various kinds of modes the OS works in. Each runlevel has a different kind of mode which ends its booting sequence depending upon the preference of the user. The various runlevels are given below and would clear any doubt you have about them:


Runlevel Mode
0 Halt
1 Single User
2 Multi User w/o Networking
3 Full multi user mode
4 Free / not used
5 Full multi user (X Based GUI)
6 Reboot

The etc/inittab file has a line towards the top that looks something like:

id::initdefault here is the default runlevel

Changing Runlevels

Whenever runlevel changes the etc/rc.d/rc starts and stops the services for the particular set of runlevels. The same file also sets the source function library which tells the kernel how to start /Kill for various processes.

The etc/rc.d/rc also starts the default system processes and checks for the default rc directory for that particular runlevel. This can be ascertained by the numbers on the directories in etc/rc.d etc/rc.d/rc<n>.d where <n> is the runlevel.

There are a number of scripts that are started at different runlevels. You can have a list of these scripts if you check out the contents of the corresponding rc.d directory for that runlevel. the contents of this directory are not files but links to the required scripts in the /etc/rc.d/init.d directory. When these scripts are run the boot process is almost complete. As soon as the runlevel scripts are run the /etc/inittab starts the getty process which then shows the virtual console or the login prompt.

References

Http://www.redhat.com Red Hat Linux Unleashed - Techmedia The official Red Hat reference guide.

This file may be mirrored along with the site by obtaining permission from the author. The electronic version of the paper is available free; you can print and distribute it without making any changes and as long as this page is included.

Corrections would greatly appreciated; please send them to sid@sidkhosla.com/ob_stinatesid@hotmail.com Siddharth Khosla B. Tech (CSE) Punjabi University Patiala India. http://www.sidkhosla.com/papersഊ

Dedicated to: My Family and Friends.ഊ