Linux Series — What happens when you press power button on Linux?
Linux boot up process is the key for any linux based systems. As an engineer, it is always important to know what happens when we start the power button and boot up the linux machine.
I have simplified the process into 8 steps and gave a mind map which talks about all the process that happens in the boot loading
Step:1 — Switch on the power button
The process starts when you press that power button to turn on the computer

Step:2 — BIOS/UEFI loads up
First, a program called the BIOS or UEFI boots up. These are basically pieces of software that get all the main parts of your computer ready for action. We are talking about the keyboard, screen, hard drives and so on.

UEFI is new on the block, offering faster boot times and better security features like secure boot, compared to the traditional BIOS.

One Key Different between BIOS and UEFI is in their approach to disk storage

BIOS is tied to the Master Boot Record(MBR) system, which limits disk size to 2 TB. UEFI on other hand uses the GUID Partition Table(GPT), removing these size constraints and offering a more flexible and modern solution
Step:3 — Power-On-Self-Test
Next, the BIOS or UEFI runs a check called the Power-on-self-test or POST. This test ensures all the bits and pieces of hardware are working right before fully turning everything on.

If POST find a problem, it will often show an error message on the screen. Finally, if everything checks out with POST, the BIOS or UEFI needs to find and load up the boot loader software.
Step:4 — Find Boot Device and boot up the boot loader software
The boot loader is usually set to check the hard drive first, then USB drives or CDs if it doesn’t find anything on the hard drive.

We can customize this order in the BIOS settings if you want.

Step:5 — Boot Code Execution
On a BIOS System, the boot loader code lives in first little chunk of the hard drive called the Master Boot Record.

For UEFI, there is a separate partition that stores files like the .efi boot loader file.
The Key Jobs of the boot loader are
- Locate the operating system kernel on the disk
- Load the Kernel into the computer’s memory
- Start running the kernel code
Some common boot loaders you might see are LILO( Linux Loader) and GRUB2. LILO is pretty outdated and rarely used in modern distributions.
GRUB2 is the full featured and widely used today. It can handle booting multiple operating systems, looks nice with graphical or text-based menus, and has bunch of advanced options for power users.

Step:6 — Hands over to Kernel
So once GRUB2 loads itself up, it inserts the linux kernel into memory and hands control over to the kernel to finish the start up process.

After the boot loader starts the kernel, the kernel takes over the computer’s resources and starts initializing all the background processes and services.
- Decompresses itself into memory
- Check Hardware
- Load Device drivers and other kernel modules
Step:7 — Initialization Process
Now the init process kicks off which is modern linux systems is typically Systemd.

Systemd replaced older init systems like SysVinit and Upstart. It is the parent of all processes on linux
Systemd has tons of responsibilities to get the system booted and ready to use. It is checking for any remaining hardware that needs drivers loaded.

It mounts up all your different file systems and disks so they are accessible. It starts by launching all the background services you need like networking, sound, power management.

They handle user login once you get to the graphical prompt . And it loads up your desktop environment with the panels and menus.

Systemd uses target configuration files to decide which mode it should be booting into something basic like multi-user text only target, or the graphical target most of us use daily. Those targets corresponds to the old run levels from past linux days if you heard of those.
Mostly now you just need to know Systemd handles initializing everything that needs to launch behind the scenes when start up linux.
Step-8-Linux system is ready

And there you go!! We have unpacked the sequence of events that transform your computer hardware into a functioning linux system when you press power button.
Happy Learning!!