Linux Boot Process
Overview: First we need to power on the linux server. Here the machines are not in working condition. So first it goes to CPU. CPU has a program called BIOS which is loaded by CPU and BIOS will handle it. BIOS will ask from bootable device from where do I need to pick the OS and use. While installing OS, CPU will get hard disk. Then CPU will goes to MBR (Master Boot Record). After this we will use GRUB (a program called Grab Unified bootloader) loads the kernel into memory and then kernel will loads the remaining process of OS.
Explanation: BIOS → MBR → GRUB → Kernel → systemD
BIOS: It is a basic input output device. It is a first program that execute which is stored inside read only memory on motherboard of the computer. Perform POST (power-on-self-test) which verify the hardware component and peripheral to ensure if computer is in working condition. Check for bootable device like pendrive, hard disk. Handover control to first sector of the bootable device i.e MBR. Apart from BIOS, UEFI (Unified Extensible Firmware Interface) is used.
MBR (Master Boot Record): It contains 512 bytes which has a code instructions to boot a machine such as a) Boot Loader ( b) Partition Table c) Error Checking (b yes). It will load the bootloader into the memory and handover to it.
GRUB: Load /boot/grub2/grub.cfg during boot time. At this stage user will see GUI which will be asking different OS or kernel. Once you selected the kernel, it will load kernel binary /boot/vmlinuz-<kernel-version>. Main job is to load the kernel and initramfs/initrd image into memory. Once loaded the kernel into RAM, it passes the control to it.
Kernel: first kernel is loaded into ROM. Initramfs/initrd get decompresses and loads the temporary file system. Initrd detects and loads the drivers from temporary file system to load the actual file system. Once main file system is mounted, kernel initializes the first process init/SystemD.
SystemD: First service loaded with process ID 1. Starts all required process /etc/systemd/system/default.target
It bring the system to run level target (0-6). You can find different runlevel files usr/lib/systemd/system