Boot Process in Linux

Leave a Comment
Ever wondered what happens when you power on your computer, what happens in the background till the time you see the linux login prompt.
This is a very common concept and frequently asked in interviews. This process will explain the basic stages  occurring during booting right from the power on to the point at which a login prompt appears.

  
The above figure shows the basic stages that occurs during boot process. Starts from BIOS stage , followed by MBR, GRUB , kernel , INIT and Runlevel.

Now i will elaborate all the sections:


BIOS

  •  BIOS stands for Basic Input/output System. 
  • It is firmware interface or program. When  you turn on your computer , Microprocessor passes  control to BIOS  which is located at EPROM
  • It performs System Integrity Checks (Connected hardware integrity checks which is called POST : Power on self test) that assures proper functioning of attached devices.
  • Detects and initialize hardware
  • Determine the device to boot from , i.e. Cd-rom  or hard drive
  • In simple terms it prepares the system to load an Operating System and executes the  MBR boot loader.

MBR

  • It stands for Master boot Record
  • Located in the first sector of bootable disk. Typically /dev/hda or /dev/sda
  • Size of MBR is of 512 bytes and it has three components : 1. Primary Boot loader Program of 446 bytes , 2.  64 bytes for Partition table info 3.  MBR validation check in last 2 bytes
  • It contains info about GRUB  and executes GRUB Boot loader

GRUB

  • GRUB stands for  Grand Unified Bootloader
  • GRUB configuration file is  /boot/grub/grub.conf
  • If there are more than one kernel images installed on computer, you can choose which one to be execute
  • It displays a Splash screen, waits for a few seconds , if you don't type anything it will load the default kernel image as specified in grub conf. file
  • So , GRUB just loads and executes Kernel and initrd images

KERNEL

  • Kernel being the heart of O.S.  handles all Operating System Process such as memory management , task scheduling and overall system control
  • Load device drivers for the devices
  • Mount the  root file system as specified in "root=" in grub.conf
  • Executes the /sbin/init program
  • As init is the first program that is executed by linux kernel, it has process ID od 1. Check the process id of the same by ps -ef |grep init' 

INIT Process


  • INIT  decides the Linux Run levels.
  • Execute  ' grep initdefault /etc/inittab ' on your system to find the run level
  • Below are the available Run Levels:
                0 - halt
                1 - Single User mode
                2- Multiuser , without NFS
                3- Full multiuser mode
                4- unused
                5- X11
                6- Reboot
  • Init  identify the default initlevel  from /etc/inittab.

Run-Levels

When you boot your linux system , you must have seen  various services getting started like starting sendmail ... OK . these are the run level programs.
As mentioned above, there are 6 run levels in Linux , from run level 0 to run level 6. Run level 0 is for halt or turn off. Run level 1 is mainly used by system administrator and used for system maintains and  repairing process. It is also called single user mode.
Run level 2 is for multi  user mode  without network while Run level 3 is for multi user mode with network.

4 is unused and 5  is for graphical mode and run level 6 is for turn off


Run levels can be identified in linux using directory
#cd  /etc/initatab


  • Depending on your default init level setting, the system will execute the programs from one of the following directories.
    • Run level 0 – /etc/rc.d/rc0.d/
    • Run level 1 – /etc/rc.d/rc1.d/
    • Run level 2 – /etc/rc.d/rc2.d/
    • Run level 3 – /etc/rc.d/rc3.d/
    • Run level 4 – /etc/rc.d/rc4.d/
    • Run level 5 – /etc/rc.d/rc5.d/
    • Run level 6 – /etc/rc.d/rc6.d/
Important files For Linux Boot Sequence"
 
Boot loader 
/etc/grub/grub.conf
/etc/lilo.conf

  
Mount NFS  partition table from the /etc/fstab file
 
Run level it will refers to the /etc/inittab file

0 comments:

Post a Comment