What happens between boot and login?

The stages involved in Linux Booting Process are:


1. BIOS


2. Boot Loader
– MBR
– GRUB


3. Kernel

4. Init Process


5. Runlevel scripts

BIOS

This is the first thing which loads once you power 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 instruction which tells the CPU to bring up the BIOS


BIOS determines all the list of bootable devices available in the system.

 

Prompts to select bootable device which can be Hard Disk, CD/DVD-ROM, Floppy Drive, USB Flash Memory Stick etc.

 

Operating System tries to boot from Hard Disk where the MBR contains primary boot loader.


Boot Loader


This phase includes loading of the boot loader (MBR and GRUB) into memory to bring up the kernel.


It is the first sector of the Hard Disk with a size of 512 bytes.
The first 434 – 446 bytes are the primary boot loader, 64 bytes for partition table and 6 bytes for MBR validation timestamp.

 

  • Now MBR directly cannot load the kernel as it is unaware of the filesystem concept and requires a boot loader with file system driver for each supported file systems, so that they can be understood and accessed by the boot loader itself.

 

To overcome this situation GRUB is used with the details of the filesystem in /boot/grub.conf and file system drivers.

MBR(Master Boot Recorder)

What  Is  GRUB  Boot  Loader?

 The boot loader’s function is to locate the Linux Kernel, and any other necessary files, and load them into memory. It then starts the kernel so that the kernel can run processes.

 

The boot loader also lets you to control how a system is booted. If you dual boot, a boot loader enables you to choose between operating systems at startup.

 

When a computer boots, the basic input/output system (BIOS) in read only memory usually loads the boot loader from the Master Boot Record (MBR) on the system’s primary hard drive.

What Are The Stages Involved in loading GRUB?

Most boot loaders execute in two or more stages. GRUB loads itself into memory by

1. loading the stage 1 boot loader

 

First the BIOS reads the stage 1 or primary boot loader into memory from the MBR.


The primary boot loader takes up less than 512 bytes of disk space in the MBR – too small a space to contain the instructions necessary to load a complex operating system.


Instead the primary boot loader performs the function of loading either the stage 1.5 or stage 2 boot loader.

2. loading the stage 1.5 boot loader

Some hardware requires an intermediate step between the stage 1 and stage 2 boot loaders.


This can happen when the /boot partition is situated beyond the 1024 cylinder head of the hard drive, or when you are using LBA (Logical Block Adressing) mode.


GRUB Stage 1.5 is located in the first 30 KB of Hard disk immediately after MBR and before the first partition.


This space is utilised to store file system drivers and modules.
This enabled stage 1.5 to load stage 2 to load from any known loaction on the file system i.e. /boot/grub

3. loading the stage 2 boot loader

 

The secondary boot loader is located somewhere on the disk – on the boot sector of the first partition.


For Example it displays the GRUB menu and command environment, which enables you to select which operating system or Linux kernel to boot.

4. loading the operating system or kernel

 

GRUB determines which operating system to start and loads the operating system or kernel and initrd into memory.


It then transfers control of the computer to the OS.

 

GRUB also supports Logical Block Addressing (LBA) mode which enables the computer to find the /boot files more easily, particularly if they are located beyond the 1024th cylinder of the hard drive.

KERNEL

What is Linux Kernel?

It acts as an interpreter between Linux OS and its hardware.

It is the fundamental component of Linux OS and contains hardware drivers for the devices installed on the system.

The kernel is a part of the system which loads first and it stays on the memory.

 

This can be considered the heart of operating system responsible for handling all system processes.

Kernel is loaded in the following stages:
Kernel as soon as it is loaded configures hardware and memory allocated to the system.

 


Next it uncompresses the initrd image and mounts it and loads all the necessary drivers.

 

Loading and unloading of kernel modules is done with the help of programs like insmod, and rmmod present in the initrd image.

Unmounts initrd image and frees up all the memory occupied by the disk image.


Then kernel mounts the root partition as specified in grub.conf as read-only.


Next it runs the init process.

Based on the selected runlevel, the init process then executes startup scripts located in subdirectories of the /etc/rc.d directory.
Scripts used for runlevels 0 to 6 are located in subdirectories /etc/rc.d/rc0.d through /etc/rc.d/rc6.d, respectively.

Lastly, init runs whatever it finds in /etc/rc.d/rc.local (regardless of run level). rc.local is rather special in that it is executed every time that you change run levels.

Next if everything goes fine you should be able to see the Login Screen on your system.

Init Process

Runlevel Scripts

Executes the system to boot into the run level as specified in /etc/inittab

What happens between boot and login?

By amisha2016

What happens between boot and login?

  • 802