Monday 18 January 2016

Boot process in detail

Linux Boot Process

1.Switch ON the system

2.Bios: POST and gives control the Boot device and loads MBR

      i)In BIOS you can mention the sequence from where it should boot i.e HDD,CD-Drive,PXE,etc
      ii)then give control to first sector of the disk
      iii)first sector have information about how to start booting from it
      iv) First sector consist of master boot record(MBR)

3.MBR execute the Boot loader(eg: GRUB)

      i) MBR know how to boot from the selected boot disk
      ii) In-case you have multiboot environment, i.e it has GRUB or LILO installed on it

4.GRUB menu list
  i) show menulist that GRUB which is loaded in MBR
  ii) Show different operating system (if you have dual boot)
 iii) which is fetched from /boot/grub*/menu.lst file

5.Grub loads Kernel and Initrd(Intial Ramdsik)


    it also contain default timeout and default selection
  i)here (hd0,0) represent first device and first partition- where kernel and initrd reside
  ii) here kernel shows in /vmlinuz* instead of /boot/vmlinuz* becoz here first hd0,0 is first device and partition is /boot partition
    a. Kernel line can specify multiple option to it like enable Selinux permission or single user mode, etc
    b. most important is root file system location ie ro root=/dev/mapper/*
iii) same applies for initrd /initramfs*
      a. Kernel is loaded with statically compiled module driver but not capable of loading root file system that why initrd comes to play. case scenario like: SCSI ,RAID modules
     b. We cant load all modules to kernel becoz it make kernel size bigger
   
6. Initrd: Intial root filesystem with required drivers
     a. Where dracut play a key role where dracut is nothing but initrd infrastructure
     b. First it load all the hardware module like SCSI,SR0,etc
     Note: Where hardware module like eg SCSI provided detail about all partition information in harddisk , likewise for all modules.
     c.then it will mount root file system but in read-only mode

7.Kernel loads the actual root system and required drivers

       a. it load udev where device modules loaded
       b. then load all the SCSI modules,ethernet modules
   
8. /sbin/init is executed 
           a. it is the first process to start after kernel is mounted and  /sbin/init  is through a reference file located in /etc/rc.sysinit
          b. fetching hostname information from /etc/rc.sysint
          c. checkout inconsistent(fsck) in file system and finally loads the file systems
          d. makeout filesystem and re-mount them in read-write mode
               eg: makeout LVM and re-mount in rw mode
          Note: it uses /etc/fstab  for mount system and mount that up all the entities in file

9.Checks runlevel in /etc/inittab

     a. then it start the system services that present in that  runlevel that we are booting into

10.Runs all the files present in /etc/rcN.d/S*

    a. Where N is replaced with runlevel number i.e incase runlevel is 3 then it check /etc/rc3.d/
   b. where service start with K should be stoped
   c. Where service start with S should be started
      Note:  this specify how script should be started

11.Runs /etc/rc.local


   a. if you want to run custom script  after boot process completed then , we can place it in /etc/rc.local.





--------------------------------------------------------------------------------------------------------------------------------

SHORT VERSION OF BOOT PROCESS:
1.Switch ON the system

2.Bios: POST and gives control the Boot device and loads MBR
a.first sector have information about how to start booting from it
b. second sector  boot from the selected boot disk

3.show menulist that GRUB which is loaded in MBR, which is fetched from    /boot/grub*/menu.lst file

4.Grub loads Kernel and Initrd(Intial Ramdsik)

5.Initrd: Intial root filesystem with required drivers
a.Where dracut play a key role where dracut is nothing but initrd infrastructure
        b. First it load all the hardware module like SCSI,SR0,etc
c.then it will mount root file system but in read-only mode

6.Kernel loads the actual root system and required drivers
        a. it load udev where device modules loaded

7./sbin/init is executed 
        a.it is the first process to start after kernel is mounted and  /sbin/init  is through a reference file located in /etc/rc.sysinit
b.checkout inconsistent(fsck) in file system and finally loads the file systems
c.makeout filesystem and re-mount them in read-write mode
Note: it uses /etc/fstab  for mount system and mount that up all the entities in file

8.Checks runlevel in /etc/inittab

9.Runs all the files present in /etc/rcN.d/S*

10.Runs /etc/rc.local

No comments:

Post a Comment