Linux Booting process / sequence in details
In this tutorial we will learn Linux Booting process or sequence.
When You press power button on your system, and after few moments you see the Linux login prompt.
following are the 6 high level stages of a typical Linux boot process.
Basic input/output System
Master boot record executes
Grand Unified Bootloader
Kernel executes /sbin/init
Init executes runlevel programs
Runlevel programs are executed
- BIOS stands for Basic Input/Output System
- This is the first thing which loads once you press
power button on your machine.
- When you press the power button of the machine, CPU
looks out into ROM for further instruction.
- The ROM contains JUMP function in the form of
instrucion which tells the CPU to bring up the BIOS
- BIOS Performs some system integrity checks
- Searches, loads, and executes the boot loader
- It looks for boot loader in floppy,cd-rom, or hard
drive. You can press a key (typically F12 or F2, but it depends on your system)
during the BIOS startup to chaange the boot sequence.
- Once the boot loader program is detected and loaded
into the memory, BIOS gives the control to it.
- So, in simple terms Bios loads executes the MBR boot
- MBR stands for Master Boot Record.
- It is located in the 1st sector of the
bootable disk. Typically /dev/had, or/dev/sda
- MBR is less than 512 bytes in size. This has three
- primary boot loader info in 1st 446 bytes
- partition table info in next 64 bytes
- MBR validation check in last 2 bytes
of disk space in the MBR – too small a space to contain the instructions
necessary to load a complex operating system.
function of loading either the stage 1.5 or stage 2 boot loader.
normally set up to load the stage 1.5.
beyond the 1024 cylinder head of the hard drive.
Disk immediately after MBR and before the first partition.
any known location on the file system i.e. /boot/grub
/boot/grub/grub.conf and any other modules needed
/grub/splash.xpm.gz with list of available kernels where you can manually
select the kernel or else after the default timeout value the selected kernel
- If you have multiple kernel images installed on your
system, you can choose which one to executed.
- GRUB displays a splash screen, waits for few
seconds, if you don’t enter anything, it loads the default kernel image as
specified in the grub configuration file.
- Grub has the knowledge of the filesystem (the older
linux loader LILO didn’t understand filesystem)
- GRUB configuration file is /boot/grub/grub.conf
(/etc/grub.conf is a link to this). The following is sample of grub.conf file.
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
Red Hat Enterprise Linux (2.6.32-71.el6.x86_64)
ro root=UUID=4afa457a-d662-4e89-b4e2-09303c44c3eb rd_NO_LUKS rd_NO_LVM
rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc
KEYTABLE=us crashkernel=auto rhgb quiet
- As you notice from the above info, it contains
kernel and initrd image.
- So, in simple terms GRUB just loads and executes
kernel and initrd images.
- This can be considered the heart of operating system
responsible for handling all system processes.
- Mounts the root file system as specified in the “root=”
- Kernel Executes the /Sbin/init program
- Since init was the 1st program to be
executed by Linux Kernel, It has the process id(PID) of 1. Do a `ps-ef |grep
init’ and check the pid.
- Initrd stands for initial RAM disk.
- Kernel as soon as it is loaded configures hardware
and memory allocated to the system.
- Initrd is used by kernel as temporary root file
system until kernel is booted and the real root file system is mounted. It also
contains necessary drivers complied inside, which helps it to access the hard
drive partitions, and other hardware.
- Executes the system to boot into the run level as
specified in /etc/inittab
- Following are available run lavels inside
(Do NOT set initdefault to this)
Multiuser, without NFS (The same as 3, if you do not have networking)
(Do NOT set initdefault to this)
- Init identifies the default initlevel from /etc/inittab
and uses that to load all appropriate program.
- Execute ‘grep initdefault /etc/inittab’ on your
system to identify the default runlavel.
- Typically you would set the default run level to
either 3 or 5.
- Depending on your default init level setting, the
system will execute the programs from one of the following directories.
- Runlevel 0 /etc/rc.d/rc0.d
- Runlevel 1 /etc/rc.d/rc1.d
- Runlevel 2 /etc/rc.d/rc2.d
- Runlevel 3 /etc/rc.d/rc3.d
- Runlevel 4 /etc/rc.d/rc4.d
- Runlevel 5 /etc/rc.d/rc5.d
- Runlevel 6 /etc/rc.d/rc6.d
- Programs used for runlevels 0 to 6 are located in
subdirectories /etc/rc.d/rc0.d through /etc/rc.d/rc6.d, respectively.
- When the linux system is booting up, you might see
various services getting started. For example, it might say “starting sendmail….OK”.
Those are the run level programs, executed from the run level directory as
defined by your run level.
I hope you enjoyed reading this article…