Linux

How Booting Process Works on Linux

Hello everyone !!

Today we are going to about step by step process booting process. Understanding how Linux boots up is very important in terms of effectively troubleshooting in case of system failure. When a system powered on and after few minutes you will get a login prompt. Have we try to find out what all stage of booting sequence has crossed and what happened behind the scene during system boots up.

The Booting process has five stages, Let examine all step by step.

System Startup :

It is the first process happened when you booted or rebooted your system. the processor executes code at a well-known location which is call basic input/output system (BIOS), which is stored in flash memory on the motherboard. The central processing unit (CPU) in an embedded system invokes the reset vector to start a program at a known address in flash/ROM.

BIOS check for all the components are connected properly with the system and then search for MBR (Master Boot Record) on the booting device mentioned in the order.

Stage 1 Boot Loader :

MBR consist physical sector of the first disk drive and it’s not part of any partition

The primary boot loader that is in the MBR is a 512-byte containing both program code and a partition table. It contains small binary  information of 1st stage of loader.

Boot Code (GRUB) 446 bytes
partition 1: 16 bytes
partition 2: 16 bytes
partition 3: 16 bytes
partition 4: 16 bytes
magic Number: 2 bytes

The job of the primary boot loader is to find and load the secondary boot loader

Stage 2 Boot Loader :

The job of stage 2 boot loader is to load the kernel & optional initial RAM disk. The combination of primary & secondary boot loader is called Boot load I.e LILO, GRUB GRUB 2 etc. LILO has some disadvantages over GRUB. GRUB 2 is the latest version.

GRUB display the available kernels, we can select it by using UP & DOWN arrow keys. If no option selected, It will load the default kernel mentioned in the configuration file /etc/grub.conf.

Kernel :

After loading kernel, the second stage boot load gives control to kernel to begin. The kernel image a compressed kernel image. Typically this is a zImage (compressed image, less than 512KB) or a bzImage (big compressed image, greater than 512KB), that has been previously compressed with zlib. At the head of this kernel image is a routine that does some minimal amount of hardware setup and then decompresses the kernel contained within the kernel image and places it into high memory. If an initial RAM disk image is present, this routine moves it into memory and notes it for later use. The routine then calls the kernel and the kernel boot begins.

Major Functions in Linux Kernel i386 Boot Process

The above figure shows the primary function flow of Linux Kernel.

Kernel Initialization :

  1. initialize CPU components, eg, MMU
  2. initialize the scheduler (PID 0)
  3. mount the root filesystem in rw mode
  4. fork off the init process (PID 1)

INIT : 

After the kernel is booted and initialized, the kernel starts the first user-space application. The first application started is commonly /sbin/init. But it need not be. Rarely do embedded systems require the extensive initialization provided by init (as configured through /etc/inittab). In many cases, you can invoke a simple shell script that starts the necessary embedded applications.

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *