Here is the video version, if you prefer it:
Today we will talk about how your computer boots up (or, equivalently, how does it start up). We will look at the first steps your computer executes when you turn it on. This will be important to understand if you ever encounter a boot-time problem. Of course, you will use Google, but having context as to what is actually happening will prove really valuable.
Your computer boots up in the following sequence of steps: (Ward, 2014)
- A boot loader is ran by machine’s BIOS or boot firmware
- The boot loader finds the kernel image on disk, loads it into memory, and starts it
- The kernel initializes the hardware devices and its drivers
- The kernel mounts the root filesystem
- The kernel starts a program called init; init has PID equal to 1
- init starts all of the other necessary system processes
- At some point at or near the end of this entire process, you get the option to log in to your system
Let’s clarify some terms here. Let’s go one by one:
- What is BIOS? BIOS stands for Basic Input/Output System and it is used to check for hardware errors andrun the boot loader. (“BIOS,” n.d.) Think of BIOS as the starting point of your computer; when you turn your computer on, it checks if all the hardware is OK and if it is, it runs the boot loader. Instead of BIOS, you can have other boot firmware (such as UEFI – Unified Extensible Firmware Interface (“Unified Extensible Firmware Interface,” n.d.)), but its job remains the same – check the hardware, if that’s OK, run the boot loader.
- What is the boot loader? The boot loader is a small program whose task is to find the kernel image on disk, load it into memory and start it. (Ward, 2014). We will talk more about boot loaders in another post, but they are a small, albeit a critical piece of code which loads the kernel.
- To review, the kernel is the “core” of the operating system and the root filesystem is the hierarchical filesystem starting from the root folder (/).
- What is init? init is a special process whose task is to start all of the other necessary system processes and init has a PID of 1. We will also talk more about init in another post (or posts).
I think we clarified all of the terms present in this article.
A caveat for the those of you who are interested in the nitty-gritty details: initramfs can be used to mount the root filesystem.When the kernel image gets loaded by the boot loader, the kernel can mount initramfs, if it exists. This is an advanced Linux detail, but I just wanted to mention it here. More information can be found in (“About initramfs,” n.d.).
Hope you learned something new!
About initramfs. (n.d.). Retrieved March 31, 2020, from http://www.linuxfromscratch.org/blfs/view/svn/postlfs/initramfs.html
BIOS. (n.d.). Retrieved February 13, 2020, from https://en.wikipedia.org/wiki/BIOS
Unified Extensible Firmware Interface. (n.d.). Retrieved February 13, 2020, from https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface
Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Pages 93-94; 97
Subscribe to my newsletter to keep abreast of the interesting things I'm doing. I will send you the newsletter only when there is something interesting. This means 0% spam, 100% interesting content.