Linux Booting Process
Linux booting process includes below stages:
•BIOS
•MBR
•GRUB
•Kernel
•Init
•Run level
•User Interface
Stage 1 - BIOS:
— BIOS is the first process begins once you power on your machine.
— BIOS determine all the list of bootable devices available in the system.
— Performs very basic level of interaction with the hardware i.e., BIOS performs a test on all the hardware components and peripherals called POST – Power on Self Test.
— BIOS search boot loaders int a floppy, CD ROM or hard drive (Boot sequence can be changed from BIOS setup during BIOS start up)
— When the Boot loader found and load into the memory, BIOS gives the control to it. So, BIOS use to loads and execute the MBR boot loader.
Stage 2 – MBR:
— Master Boot record
MBR is responsible for loading and executing the GRUB boot loader.
— MBR located into the first sector of the bootable drive. Generally, /dev/had or /dev/sda.
— MBR stores in 512 bytes in size, there are 3 components of MBR
•Primary boot loader information stored in 1st 446 bytes.
• Partition table information stored in the next 64 byte (16 X 4)
•MBR validation check stored in the last 2 byte.
Stage 3 – GRUB:
^Grand Unified Bootloader.
^It stores all the information about OS image to load and execute Kernel & initrd (initial RAM disk) images.
^Note: If more than one OS available, all those details will be available in this GRUB file and can set a default one among different OS.
^GRUB has the knowledge of the file system in the OS.
^GRUB configuration files are available at /boot/grub/grub.config
Stage 4 – Kernel:
^When Kernel loads, it mount the root file system and execute /sbin/init program.
^Kernel is the heart of OS responsible for handling all system processes.
Kernel is loaded in the following steps.
^Once the Kernel is loaded, it configures hardware and memory allocated to the system.
^Decompresses the initrd (Initial RAM disk) and mounts it and loads all the necessary drivers.
^Loading and unloading of kernel module is done with the help of programs like ins mode and rm mode present in the initrd image.
^Look for the hard disk types be it a LVM or RAID.
^Unmount initrd image and frees up all the memory occupied by the disk image.
^Then Kernel mounts the root partition as specified in the grub.conf as read only.
^Next it runs the init process (/sbin/init program)
Kernel then establish a temporary root file system using initial RAM disk(initrd) until the real file systems are mounted.
Stage 5 – init Process:
^Init is the first process started by Kernel. It is the parent of all process.
^Note: As init was the 1st program to run by the linux kernel, it has one (1) as process id (PID), which can be checked by using the command – ps -ef | grep init
It checks file /etc/inittab to decide the linux run level.
^There are 7 run levels available with the linux OS.
•init0 ( halt/shutdown
•init1 ( Emergency mode
•init2 ( Multi user without NFS
•init3 ( Full multi user / minimal version
•init4 ( Unused, Research work
•init5 ( GUI mode
•init6 ( Reboot
^init will check and identifies the default init level from the file /etc/inittab to load all appropriate program required for the run level.
^The System’s default configured run level can be checked by using the command – grep initdefault /etc/inittab.
Stage 6 – Run level:
^This executes all the required program for that respective run level and it depends on the init level.
^The process running can be checked in the directory - /etc/rc.d/rc*.d
The process starting with
^S denotes STARTUP ( used during start up
^K denotes KILL ( used during Shutdown
Errors in Booting process:
BIOS:
•Physical system issue ( issue in RAM, hardisk, mother board etc
MBR:
•Booting priority issue ( issue in OS, OS missing
GRUB:
•Issue arises if the /boot is corrupted ( reinstall or rebuild the GRUB
Kernel:
•Kernel panic Error ( Due to heavy load, Memory overlap, exceeds the configured requirement
Kernel Image Error ( due to corrupted image – rebuild the image to rectify this
init:
if the mounted disks are removed or OS was not able to run – it will leads to init2 mode (emergency mode)
Run level:
Configuration issues, loops