Live as if you were to die tomorrow. Learn as if you were to live forever.

Friday 19 December 2014

Linux Boot Procedure


Step I: Once you power on the system it performs the POST (Power On Self Test). POST check if connected devices are working properly and ready to use. Once the POST will complete, BIOS will take the control of the booting procedure and it loads the MBR.

Step II: MBR is the Master Boot Record which present in the first sector of the Hard Disk. The size of MBR is 512 bytes.

MBR contains:
(i)                 Primary Boot Loader (446 Bytes)
(ii)               Partition Table (64 Bytes)
(iii)             Magic Number (2 Bytes)

Later we will see details about the MBR.

Now, MBR load the GRUB boot loader.


StepIII: GRUB is the Grand Unified Bootloader. GRUB configuration file is /grub/grub.conf. As we know that grub.conf contains the information regarding the kernel and it load the kernel and initrd(Initialization of Ram Disk)

Grub loads the user selected kernel into the memory and passes the control to the kernel. If you don’t select any kernel then after some time GRUB will load the default kernel into the memory.

Now the control is towards the kernel.

Step IV: Initrd is used by kernel as temporary root file system until the real root file system is mounted. Initrd also contains the driver which helps to access connected hardware.

Kernal mounts the root file system mentioned in the grub.conf file as read only and it runs the init process.

Step V: Init identifies default run level from /etc/inittab.
            There are total 7 run-levels (0-6) in linux
0                    Halt/Shutdown
1                    Single user mode
2                    Multiuser without NFS
3                    Full multiuser
4                    Unused
5                    X11 (Graphical Mode)
6                    Reboot

Based on appropriate run level scripts are executed to start and stop various processes to run the system.
Init having process ID 1.

Later we will discuss about run-levels in details.

Once the initialization of run-level completes, init process run one more file called /etc/rc.local which are the last command in the booting procedure. Once everything is completed control goes back to the kernel.

Step VI: Once kernel get the control of the booting procedure it start multiple instances of getty which waits for login console. You will get a login screen to log inside your booted system.

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Simple and very easy to understand

    Thanks for the such good explanation.

    ReplyDelete