Have you ever wondered what happens while LINUX boot?
Then you are at the right place !!!
The Boot process is the primary thing to know by all Linux users / administrators. Ofcourse it is one of the important interview questions of all the time.
Then you are at the right place !!!
The Boot process is the primary thing to know by all Linux users / administrators. Ofcourse it is one of the important interview questions of all the time.
[it is important to know the boot sequence which helps us to analyze the boot logs, understand what exactly happening at boot time and troubleshooting various boot related issues]
The process behind the scene, when we turn on the system
and until the login prompt appears. This entire
process is nothing but " boot process / boot sequence".
There are 6 stages available in Linux
boot process:
Boot Process stages
BIOS:
- Basic Input/output system (BIOS) will run (POST - Power On Self Test) to check all hardware and its operating state.
- BIOS gets loaded in memory and checks system, connected peripherals, boot device (cd-rom ,floppy, hard disk) path.
- BIOS will determines the boot loader program and loads into memory.
- Once boot loader program is loaded, BIOS hand over boot control to it.
MBR:
- MBR is located in first sector of bootable drive, which is of size 512 bytes.
- This 512 bytes is comprise of 446 bytes for primary boot loader, 64 bytes for partition table and 2 bytes for MBR validation check. [ 512 = 446 + 64 + 2 ]
- MBR contains the information about GRUB/LILO
- LILO is Linux Loader which was used for old system.
- Now boot control will move to GRUB stage.
GRUB:
- Grand Unified Boot Loader.
- The main config file for GRUB is /etc/grub.conf
- It will display a splash image with the list of available kernels in your system and wait for few seconds.
- You can use Arrow keys and select the required kernel to load otherwise it will load the default kernel in a specified time present in /etc/grub.conf file.
sample grub.conf file :
- It will have the details related to kernel and initrd image.
- initrd - Initial Ram Disk is used to temporarily mount the root file system
- The initramfs is used by the kernel to load drivers and modules necessary to boot the system.
- Once kernel and initramfs is loaded into memory, then the boot control will goes to kernel.
KERNEL:
- Kernel will initialize and configure the system's memory and the hardware of the system ( processor/storage devices).
- It will also helps to load all the necessary drivers.
- kernel mounts the root partition as read-only, and free up any unused memory.
- Kernel will execute /sbin/init. Since it is the first process which is generated by kernel, init will have PID as 1 . Thus init is the parent or ancestor process of all process
- Now the control will goes to init.
INIT:
- /etc/inittab file contains the run levels as follows:
sample inittab file:
- Usually the default runlevel will be either 3 or 5, depends on your system.
- Commands to check runlevel:
# who –r
# runlevel
Runlevel:
- The Runlevel directories will look's like /etc/rc.d/rc*.d
- Here * can be replaced by 0 to 6 . For ex: runlevel 0 will make use of /etc/rc.d/rc0.d
Runlevel 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
- Depending on the selected runlevel, the init process will executes startup scripts under the subdirectories of /etc/rc.d directory.
Thus Boot Process is completed.
If everything goes fine, you should be able to see the Login prompt on your system.
-----------------------------------------------------------------------------------------------------------------------------------------------------
Thanks 😊
Post a Comment