A Basic Guide to Different Stages of Linux Boot Process


As promised in our earlier post, in this post we are going to review boot process in Linux Operating System. How Operating system passes through different stage of booting states. This article is written for those readers who has just steps in Linux world. Understanding how Linux boots up is very important in terms of effectively troubleshooting in case of system failure. When a system switched on and after few moment we 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.

In Linux world, there are 6 stages of booting. Lets discuss one by one in details:
Linux Boot Loader Process

Linux Boot Loader Process

1. BIOS (Basic Input Out System)

  • System power on, hardware transfer control to BIOS.
  • BIOS is the first program to run and it’s OS independent.
  • BIOS resides on ROM (Read only Memory).
  • First step of BIOS (Basic Input Out System) is the Power on self test (POST) which scan
    hardware information and checks for bootloader.
  • Scans for boot devices (Floppy, CD and/or DVD drive). During that period we can press
    keys (F2, F12) depends on your system to change boot sequence.
  • BIOS reads very first sector of hard drive. That is called boot sector where Bootloader
    resides. Once bootloader is detected and BIOS loads and provide control to bootloader and
    start processing next level of booting sequence.

2. MBR (Master Boot Record)

  • Master Boot Record (MBR) is located in the First Sector of bootable disk.
  • Bootloader may resides in the MBR or may elsewhere.
  • MBR which has 512 bytes in size which has three components.
    1. The first 446 bytes are for primary boot loader which contains executable code.
    2. Next 64 bytes are for partitiontable information.
    3. Last 2 bytes is used for Magic number (validation check of MBR).
  • MBR contains GRUB/LILO information then execute GRUB/LILO bootloader.

3. GRUB (GRand Unified Bootloader)

  • GRUB Stands for (GRand Unified Bootloader). GRUB has its own menu interface and has ability to navigate filesystem.
  • Displays a list of available kernels defined in /etc/grub.conf. Provide options to choose if multiple kernel image is installed. Below is CentOS grub.conf file where we can see kernel and initrd image.
#boot=/dev/sda
default=0
timeout=5
password --md5 $1$19oD/1$NklcucLPshZVoo5LvUYEp1
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-279.el6.i686)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-279.el6.i686 ro root=/dev/mapper/vg_tecmint-lv_root 
rd_NO_LUKS rd_LVM_LV=vg_tecmint/lv_swap LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 
crashkernel=auto rd_LVM_LV=vg_tecmint/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb 
quiet
        initrd /initramfs-2.6.32-279.el6.i686.img
  • GRUB display splash screen and wait for few seconds to intervene, if not it will loads
    default kernel image.
  • GRUB Bootloader starts Kernel and loads initrd images.

4. Kernel

  • Mount root file system.
  • Kernel starts INIT process. Since it’s first process to start by kernel which has
    Process ID (PID) of 1.
  • Loads initrd module. initrd (initial RAM disk) is a temporary root file system loaded in
    RAM until root file system mounted.

5. INIT

  • INIT (father of all processes).
  • INIT (short for initialization) deamon spawn all other processes
  • INIT looks for file /etc/inittab for instructions to proceed.
  • Here’s the inittab from CentOS.
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:
  • Runs scripts /etc/rc.d/*

6. Runlevel Programs

There are seven runlevels and it has its own significant in Linux Operating system. The
different run levels are as follows:

  • Run Level 0Halt
  • Run Level 1 – Single user mode
  • Run Level 2 – Multiuser but without NFS
  • Run Level 3 – Full multiuser mode
  • Run Level 4 – unused / User-definable
  • Run Level 5 – X11
  • Run Level 6 – reboot

As per default runlevel settings, system will reads and execute the programs from
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/

/etc/rc0.d/ is linked to /etc/rc.d/rc0.d/ directory. Under /etc/rc.d/rc0.d/ directory we could see programs starting with S and K which means startup and kill respectively. Also there are sequence number next to S and K. Those sequence number in which the programs should be started or killed during boot up.

By: http://www.tecmint.com; CLC4U.WORDPRESS.COM

ឆ្លើយ​តប

Fill in your details below or click an icon to log in:

ឡូហ្កូ WordPress.com

អ្នក​កំពុង​បញ្ចេញ​មតិ​ដោយ​ប្រើ​គណនី WordPress.com របស់​អ្នក​។ Log Out / ផ្លាស់ប្តូរ )

រូប Twitter

អ្នក​កំពុង​បញ្ចេញ​មតិ​ដោយ​ប្រើ​គណនី Twitter របស់​អ្នក​។ Log Out / ផ្លាស់ប្តូរ )

រូបថត Facebook

អ្នក​កំពុង​បញ្ចេញ​មតិ​ដោយ​ប្រើ​គណនី Facebook របស់​អ្នក​។ Log Out / ផ្លាស់ប្តូរ )

Google+ photo

អ្នក​កំពុង​បញ្ចេញ​មតិ​ដោយ​ប្រើ​គណនី Google+ របស់​អ្នក​។ Log Out / ផ្លាស់ប្តូរ )

កំពុង​ភ្ជាប់​ទៅ​កាន់ %s