DEV Community

Explain the Boot Sequence Like I'm 5

How do the hardware, bootloader, firmware, BIOS, OS, ... whatever is involved, interact to get a computer from completely off, to a usable state?

Top comments (5)

Collapse
 
zasuh_ profile image
Žane Suhadolnik

For a successful boot 3 things need to work properly: BIOS (Basic Input Output System), the operating system and the hardware components. If one of these doesn't work the boot sequence WILL NOT happen.

First off when the computer gets power it gives power to the CPU which uses the internal clock to generate "clock ticks" using something called a system clock. Then the system looks at the ROM to see the startup settings. The ROM then runs the POST (Power On Self Test) and then POST checks BIOS and CMOS RAM. If POST does not detect any errors or issues with the startup or hardware, it then starts the CPU, GPU, HDD/SSD, RAM, Display, Keyboard, Mouse etc.

Then the BIOS loads the operating system, which is usually loaded from the C drive. After that the BIOS copies files and the OS is now the master of the boot sequence. OS again checks all the hardware components, loads applications, sets up a network connection and so on. After this the computer can be used.

Not exactly ELI5, but this was the best I could do. Maybe someone will give a more simple answer.

Collapse
 
mdabek profile image
Marek Dabek

On modern platforms this is far more complicated, since there are multiple hardware components with firmware on them. The OS booting sequence is also nowhere near it was 20 years ago.

If you want to consider the completely off, you need to unplug the power cord from your PC (and yet there is a small battery there) - this is called the G3 state. Then, when you plug the power cord again (this is G2 or S5 state) some of the HW is starting. This HW may be waiting for a specific input, like your Etherenet controller may be waiting for "magic packet", which will wake up the platform. But Ethernet controller itself may not wake up the platform, it will signal bus controller to which it is connected. The bus controller should eventually signal the correct piece of hardware, which can initiate the power up sequence, usually this is Power Management Unit/Controller. Now the platform starts its transition from S5 to S0 power state.

The BIOS itself may be pre-loaded by the external HW/FW component which will verify its digital signature. The modern BIOS architecture, UEFI, defines a pre-initializer, which takes the necessary steps to allow loading the rest of the BIOS. Then, the Driver Execution Environment is prepared, which allows to load additional hardware/software drivers. If you have any kind of drive encryption present, this may also be done in UEFI BIOS.

The OS also uses pre-loading, which initializes HW for the full OS load (e.g. re-initializes CPU, loads basic drivers for the HDD controller, etc.). The pre-loader may also check if the OS image is valid. Once the kernel is booted there may be basic services starting, non-critical drivers load etc.

It is really difficult to give an answer which covers all the possible aspects of the booting sequence. Lots of features used during boot is designed for security reasons, and are there to prevent loading malware infected OS components. Also the boot sequence is platform and OS specific.

Collapse
 
maj_variola profile image
maj_variola

Explain why systemd is the devil's spawn to a 5 year old.

Collapse
 
lpasqualis profile image
Lorenzo Pasqualis • Edited

Taking the “like I am 5” part seriously.
You turn on the computer. The computer wakes up. The computer yawns and blinks. The first thing it remembers is the BIOS, which is part of the firmware. The BIOS makes the computer slap itself in the face. Slap! Ouch! That makes the computer wake up even more and load the boot loader from disk. The boot loader is like a piece of paper that tells the computer where to find the OS and how to load it. The computer reads the message on the piece of paper and loads the OS.
When the OS is loaded, the computer is up and ready for a morning run.

Collapse
 
andy profile image
Andy Zhao (he/him) • Edited

Would love an answer to this, too.