[For beginners] Illustrated explanation of the mechanism from turning on the server to completing booting
table of contents
Hello.
I'm Kita from Beyond, who obtained super rare characters in the Great Cat War and is unrivaled.
Last time, I blogged about
hardware articles This time, I will explain in an easy-to-understand way how the server works from when it is powered on until it completes startup.
We usually casually start and stop servers in the cloud, but fewer people than we think understand the process that leads to that point.
(I was one of them too)
This time, I will explain the boot order in a way that even beginners can understand, including illustrations, so please read until the end.
Overall view when starting a Linux server
First of all, to conclude, a Linux system starts up as follows.
Firmware (BIOS/UEFI) → Bootloader → Kernel → init processing
However, it is difficult to understand with just this information, so I will explain it in more detail using diagrams.
There are a total of 8 steps from turning on the power to completing startup.
Roughly speaking, startup is completed as follows.
- Boot into BIOS/UEFI
- Hardware detection runs
- Boot device selection process runs
- GRUB starts
- kernel starts
- initramfs starts
- systemd starts
- Startup completed
Using the overall diagram, the flow is as shown above, and the entire system startup process is called a boot, and the process
from BIOS/UEFI startup to the above series of steps is called a "boot sequence" or "boot-up"
process. Next, we will explain the details of each item.
Description of each item
①BIOS/UEFI boot
when you press the power button on your computer and thing that runs is BIOS/UEFI.
BIOS/UEFI is installed in the ROM of the motherboard, and its role is to initialize various devices installed in the computer before starting the OS, and to properly start the OS.
There is a difference between BIOS and UEFI, but as you can see in the diagram, UEFI is an improved version of BIOS.
However, this does not mean that only UEFI is sufficient; currently, both coexist.
Functionally, both are similar, but UEFI has improved the operability of the conventional BIOS, which is complicated.
②Hardware detection
Next, we will explain hardware detection.
One of the BIOS processes called
POST (Power-On Self-Test) that recognizes, checks, and initializes connected hardware so that it can be used.
③Boot device selection
Next, the boot device selection process runs.
This is also one of the BIOS processes, and after performing POST (hardware recognition), the boot device (storage containing the OS) is selected.
The boot device is the storage (HDD/SSD) that contains the program that you want to run first when you start the server.
It is easy to understand if you remember that boot device = storage that contains the OS you want to boot
④Start bootloader
Next, the BIOS starts the boot loader stored in the boot device.
A bootloader is a program that recognizes and starts the OS (kernel) .
Many Linux systems use GRUB as their boot loader, and
there are two types of GRUB: "GRUB Legacy", which has been used for a long time, and "GRUB 2".
*Support for GRUB Legacy has already been discontinued.
Modern operating systems basically use the new version of GRUB 2.
⑤Kernel startup
Now it's time to start the kernel.
The kernel is the core program of Linux, and is also called Linux in the narrow sense.
It is mainly responsible for controlling the hardware connected to the server.
In summary, BIOS/UEFI starts the boot loader (GRUB) contained in the boot device, and the boot loader starts the kernel.
⑥Start initramfs
The kernel then starts the initramfs to access the data needed to boot the system.
⑦Start systemd
After the initramfs mounts the root file system, the kernel loads and boots ``systemd''.
systemd is the first process (PID=1) that is created when the system starts.
It is an abbreviation for "system daemon," and a daemon resides in memory and has the role of controlling the entire system.
A daemon is a program that starts when the system starts and continues to run in the background while the system is running.
⑧Startup complete
Finally, the startup will be completed.
After systemd is called by the kernel, it sequentially generates the "child processes" necessary for system operation, and the login screen will be displayed.
summary
Finally, I will summarize and review the flow up to startup.
- First, press the power button to start the BIOS/UEFI (firmware)
- BIOS initializes hardware via POST
- BIOS selects boot device from recognized hardware
- BIOS launches the bootloader stored on the boot device
- The bootloader reads the kernel from the selected boot device and starts it.
- kernel starts initramfs
- initramfs allows the kernel to handle data needed to boot the system
- systemd takes over processing, generates child processes necessary for system operation, initializes the system, and displays the login screen
That's how it went.
lastly
Up to this point, we have explained in detail about BIOS/UEFI, boot devices, boot loaders, initramfs, systemd, etc. from the point of turning on the power to completing booting.
Since it has become common for the computer to start up, it may be rare to have the opportunity to understand the startup process, but it will be useful knowledge when troubleshooting if the startup does not work properly. I hope that this article will help you understand the process of starting a server.
was created with reference to the video of
Nezumiya's Infrastructure Engineer Dojo, a channel operated by our company This is a great channel where you can learn knowledge about infrastructure from scratch, so if you are interested, please subscribe to the channel and give it a high rating!