From power-on to login

Video 063 of 140 in Virtualization Foundations, in the unit “The boot sequence, end to end”. 3:39, with English and Hindi audio.

When you press the power button on a Linux server, a login prompt appears a few moments later. In between, the machine runs a chain of small programs, and each one loads a bigger one. Knowing the chain helps you find the place where a server stopped when it does not come back. This article walks through the six steps in order, and shows how to read them on a server that is running.

What you will learn

Why start-up runs as a chain

When the power comes on, the memory of the server is empty. The operating system sits on a disk, but no program is ready to load it. So start-up works as a chain. A small program loads a bigger one, and the last link loads the kernel, the core of Linux. The kernel then starts the rest of the system.

The chain has six steps: power on, firmware, the boot loader, the kernel, systemd and the login prompt. Each step hands control to the next one.

Steps one to three: before the kernel

The initramfs is a small set of temporary files. The kernel needs the drivers inside it to reach the real disk, so the boot loader loads it alongside the kernel.

Firmware keeps its code on the chip even when the power is off. That is why it is always there to start the chain.

Steps four to six: the kernel and after

Why the order matters when a server stops

The steps always run in the same order, so the place where a server stops tells you which step failed. If the boot stops before the login prompt, the steps after the stopped one never ran.

Imagine Harbor Point Logistics, a fictional company whose customer portal runs on a Linux web server. After a short power cut, the server restarted by itself. The engineer watched the console, and the steps ran one after another until a login prompt appeared.

Reading the steps on a running server

You can see parts of the chain on a running server. The exercise below runs three commands that show the kernel version, the boot target and the boot time. None of them change the server.

Try it yourself

You need a shell on a running Linux server. Each command reads one part of the boot.

  1. Show the kernel version that is running now. The kernel is the core that starts the rest of the system.

    uname -r

    What you should see: The kernel version that is running now.

  2. Show the target that the boot aims for. A target is a named group of services.

    systemctl get-default

    What you should see: The target the boot aims for.

  3. Show how long the boot took.

    systemd-analyze

    What you should see: How long the boot took.

Terms

Firmware
A small program stored on a chip on the motherboard. It runs when the machine powers on, and it finds a disk that can boot.
Boot loader
The program that loads the kernel and the initramfs into memory. On Linux it is usually GRUB.
Initramfs
A small set of temporary files, loaded into memory, that carries the drivers the kernel needs to reach the real disk.
Kernel
The core of Linux, which starts the hardware, mounts the root disk and starts systemd.
systemd
The first real program the kernel starts. It becomes process ID one and starts the services a server needs.

Check yourself

Why can the operating system not load itself when the power comes on?

The operating system lives on a disk, and the memory is empty, with no program ready to load it. That is why start-up works as a chain.

What does systemd do after the kernel starts it?

It becomes process ID one and starts the services the server needs.

What does a login prompt tell you?

That the six steps have finished, and the console and SSH are ready for a user.

Previous: Reading the hardware inventory with dmidecode. Next: What firmware does at power-on.