6 stage System Startup Concepts: How Your Linux System Boots Up

6 stage System Startup Concepts: How Your Linux System Boots Up

When you press the power button on your computer and wait for a while, you eventually see the Linux login prompt. But have you ever wondered what actually happens during that time?

  1. Power on: When you press the power button, the computer starts receiving electricity, and it wakes up from a completely turned-off state.

  2. BIOS/UEFI: The computer's built-in software called BIOS or UEFI kicks in. It performs a quick check to make sure all the important hardware components are working correctly.

  3. Boot loader: The BIOS/UEFI then looks for a specific program called the boot loader. This program's job is to find and start the Linux operating system.

  4. Linux initialization: Once the boot loader is found and executed, it hands over control to the Linux operating system. Linux starts initializing various components, like drivers and services, getting everything ready for you to use.

  5. Login prompt: After Linux has finished setting up, it displays the login prompt on the screen. This is where you can enter your username and password to access your Linux system.

In simple terms, when you turn on your computer, it goes through some checks, finds the boot loader, starts Linux, and finally shows you the login prompt so you can log in and start using the system.

Hold on! Now let us dive into a simpler explanation of the high-level stages of the Linux boot process:

First Stage Boot Ladder

1) BIOS:

The computer's built-in software performs system checks and looks for the boot loader program.

  1. Basic Input/ Output System

  2. Searches, loads and executes Integrity Checks

  3. To change Boot sequence - Press F12 or F2

  4. BIOS loads and executes MBR Boot loader.

2) MBR:

Located on the bootable disk, contains information about the GRUB boot loader.

  1. Master Boot Record

  2. Generally Located in /dev/hda or /dev/sda

  3. Size of MBR is less than 512 byte

  4. 3 Components: Primary Boot Loader (446 byte), Partition Table info (64 byte), MBR validation check (2 byte)

  5. Loads and executes GRUB Boot loader.

Second Stage Boot Ladder

3) GRUB:

Allows you to choose the kernel image to load and executes it.

  1. Grand Unified Bootloader

  2. For multiple kernel images installed on your system, you can choose which one to be executed

  3. GRUB displays a splash screen, and waits for a few seconds, if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file

  4. Loads and executes Kernel and initrd images

4) Kernel:

Mounts the root file system and executes the /sbin/init program, which sets the run level.

  1. Executes the sbin/init/program, which is the first program to run in the Linux kernel

  2. The /sbin/init program is assigned a process ID (PID) of 1, indicating its importance as the initial program.

  3. The kernel also uses an initial RAM disk (initrd), which serves as a temporary file system until the real file system is mounted. The initrd contains essential drivers needed to access the hard drive partitions and other hardware components.

5) Init:

Reads the /etc/init tab file to determine the default run level and loads appropriate programs.

  1. Looks at the /etc/inittab file to decide the Linux run level

  2. Available run levels:

    1. 0 - halt

    2. 1 - single user mode

    3. 2 – Multiuser, without NFS

    4. 3 – Full multiuser mode

    5. 4 – unused

    6. 5 – X11

    7. 6 – reboot

  3. Init looks for the default run level in the /etc/inittab file to determine which programs and services to load

  4. You can identify the default run level on your system by executing the command 'grep initdefault /etc/inittab'

  5. It's important to note that setting the default run level to 0 or 6 can cause trouble. Run level 0 signifies system halt, and run level 6 represents system reboot. It's generally not recommended to set the default run level to these values unless you have specific requirements

  6. Typically, the default run level is set to either 3 or 5, depending on the desired system behavior and whether you want a text-based interface (run level 3) or a graphical user interface (run level 5).

6) Runlevel programs:

Programs specific to the chosen run level are executed from corresponding directories (/etc/rc.d/rc*.d/), starting with "S" for startup and "K" for the shutdown.

  1. During the boot-up process of a Linux system, you may notice various services starting up, indicated by messages like "starting sendmail... OK."

  2. These services are part of the runlevel programs, which are executed based on the run level directory defined by your system's default init level

  3. Each run level has a corresponding directory where these programs are stored:

    • 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/

  4. Symbolic links are available in the /etc directory that point to these run level directories. For example, /etc/rc0.d is linked to /etc/rc.d/rc0.d

  5. Within the /etc/rc.d/rc*.d/ directories, you will find programs starting with either "S" or "K"

  6. Programs starting with "S" are used during system startup (S for startup), while programs starting with "K" are used during system shutdown (K for kill)

    The programs have numbers next to the "S" or "K" in their names, indicating the sequence in which they should be started or stopped

  7. For example, "S12syslog" starts the syslog daemon with a sequence number of 12, while "S80sendmail" starts the sendmail daemon with a sequence number of 80. This means that the syslog program will be started before the sendmail program

Hence, during the Linux boot process, the computer checks its systems, finds the boot loader, loads the kernel, executes initialization programs, and starts the services needed for the chosen run level.

So, the next time you power on your Linux machine, remember the journey it takes to present you with the login prompt. And as you embark on your Linux adventures, may your systems run smoothly, and may you continue to explore the endless possibilities offered by this powerful operating system.💎

Now, armed with this knowledge, go forth and embrace the wonders of Linux!

If you found this article helpful, feel free to share it with others who might benefit from understanding the Linux boot process. And if you have any further questions or topics you'd like to explore, please let me know. Happy Linux computing!👩‍💻

Find me on Twitter