The Linux Booting Process Explained ๐Ÿงโ†“

When you press the system's power button, you will see the login screen on your screen and the system will begin working. Have you ever wondered what happens between pressing the power button and seeing the login screen show up?

For any operating system, there is a boot process that is executed one by one until you reach the operating system's login screen.

In this thread, we'll go through the Linux boot process step by step. The Linux boot process is divided into six high-level stages: โ€ข BIOS โ€“ Basic Input/Output System executes MBR โ€ข MBR โ€“ Master Boot Record execute GRUB โ€ข GRUB โ€“ Grand Unified Bootloader executes Kernel

โ€ข Kernel โ€“ Kernel executes /sbin/init โ€ข Init โ€“ Init executes runlevel programs โ€ข Runlevel โ€“ Runlevel programs are executed from /etc/rc.d/rc*.d/

Stage 1: BIOS BIOS is an abbreviation for Basic Input/Output System. In layman's terms, the BIOS's responsibilities are to locate and execute a boot loader (GRUB, LILO) program. When you initially power on your computer, the BIOS examines the HDD or SSD for integrity.

The BIOS then searches for, loads, and runs the boot loader program stored in the Master Boot Record (MBR). The MBR is sometimes kept on a USB stick or CD-ROM, such as during a live Linux installation.

When the boot loader program is detected, it is loaded into memory and the BIOS gives it control of the computer.

Stage 2: MBR MBR is an abbreviation for Master Boot Record. It's responsibility is to load and run the GRUB boot loader. MBR is found in the first sector of the bootable drive. In most cases, /dev/had or /dev/sda.

MBR is 512 bytes in size and consists of three components. The primary boot loader information is stored in the first 446 bytes. The next 64 bytes include partition table information. The last two bytes contain an MBR validation check.

In older systems, the MBR also stores information about GRUB, or LILO.

Stage 3: GRUB GRUB is an abbreviation for Grand Unified Bootloader. It contains all information about the operating system image that will be loaded and executed.

If you have more than one operating system, all of them will be listed in this GRUB file, and you can choose which one to use as the default.

On system boot, GRUB displays a splash screen and waits for user input to select an operating system; if you do not type anything, it loads the default kernel image supplied in the grub configuration file. Grub is familiar with your operating system's filesystem.

The GRUB configuration file can be found in "/boot/grub/grub.conf.

Stage 4: Kernel The kernel is frequently referred to as the heart of every operating system, including Linux. It has complete control over your entire system.

During this stage of the boot process, the GRUB-selected kernel initially mounts the root file system defined in the grub.conf file. Then it runs the /sbin/init program, which is always the first one to run. This is confirmed by its process id (PID), which should always be 1.

The kernel then uses Initial RAM Disk (initrd) to create a temporary root file system until the real file system is mounted.

Stage 5: Init At this moment, your system executes runlevel applications. To determine the Linux run level, it would look for an init file, normally found at /etc/inittab.

Instead, modern Linux systems use systemd to select a run level. The Linux operating system includes seven (7) different run levels. โ€ข 0 โ€“ halt โ€ข 1 โ€“ single-user mode โ€ข 2 โ€“ Multiuser, without NFS โ€ข 3 โ€“ Full multiuser mode โ€ข 4 โ€“ unused โ€ข 5 โ€“ X11 โ€ข 6 โ€“ reboot

Init will examine and identify the default initlevel from the file "/etc/inittab" in order to load all appropriate programs for the run level. You may determine your system's default run level by running the following command: $ grep initdefault /etc/inittab

Stage 6: Runlevel There is only one default run level; it will execute all essential programs for that run level. The system will examine and execute run-level programs from the folders listed below:

โ€ข 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/

It should be noted that the actual location of these directories vary from distribution to distribution. You'll find programs that begin with a "S" or "K" for startup or kill in the various run level directories.

Startup programs are run during system startup, and kill programs on system shutdown.

This information should be sufficient to help you understand the Linux booting process. That's all! Thank you for getting this far. I hope you find this thread useful.

If you found this thread valuable: 1. Toss us a follow for more daily threads on Linux, sysadmin and devops โ†’ @linuxopsys 2. Like and RT the first tweet so other Linux folks can find it too.

Follow us on Twitter

to be informed of the latest developments and updates!

You can easily use to @tivitikothread bot for create more readable thread!
Donate ๐Ÿ’ฒ

You can keep this app free of charge by supporting ๐Ÿ˜Š

for server charges...