Breaking News
Loading...
Wednesday, August 28, 2013

Linux Boot Process

8:08 AM

 Step 1. BIOS (Basic Input Out System)

  1. System power on, hardware transfer control to BIOS.
  2. BIOS is the first program to run and it’s OS independent.
  3. BIOS resides on ROM (Read only Memory).
  4. First step of BIOS (Basic Input Out System) is the Power on self test (POST) which scan
    hardware information and checks for bootloader.
  5. 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.
  6. 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.

Step 2. MBR (Master Boot Record)

  1. Master Boot Record (MBR) is located in the First Sector of bootable disk.
  2. Bootloader may resides in the MBR or may elsewhere.
  3. 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).
  4. MBR contains GRUB/LILO information then execute GRUB/LILO bootloader.

Step 3. GRUB (GRand Unified Bootloader)

  1. GRUB Stands for (GRand Unified Bootloader). GRUB has its own menu interface and has ability to navigate filesystem.
  2. 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
  1. GRUB display splash screen and wait for few seconds to intervene, if not it will loads
    default kernel image.
  2. GRUB Bootloader starts Kernel and loads initrd images.

Step 4. Kernel

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

Step 5. INIT

  1. INIT (father of all processes).
  2. INIT (short for initialization) deamon spawn all other processes
  3. INIT looks for file /etc/inittab for instructions to proceed.
  4. 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:
  1. Runs scripts /etc/rc.d/*

Step 6. Runlevel Programs

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

  1. Run Level 0Halt
  2. Run Level 1 – Single user mode
  3. Run Level 2 – Multiuser but without NFS
  4. Run Level 3 – Full multiuser mode
  5. Run Level 4 – unused / User-definable
  6. Run Level 5 – X11
  7. Run Level 6 – reboot
As per default runlevel settings, system will reads and execute the programs from
following directories.

  1. Run Level 0 – /etc/rc.d/rc0.d/
  2. Run Level 1 – /etc/rc.d/rc1.d/
  3. Run Level 2 – /etc/rc.d/rc2.d/
  4. Run Level 3 – /etc/rc.d/rc3.d/
  5. Run Level 4 – /etc/rc.d/rc4.d/
  6. Run Level 5 – /etc/rc.d/rc5.d/
  7. 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.
 

0 comments:

Post a Comment

 
Toggle Footer