Where a boot stops when it fails

Video 068 of 140 in Virtualization Foundations, in the unit “The boot sequence, end to end”. 4:29, with English and Hindi audio.

When a Linux server will not come up, the first question is where the boot stopped. The boot is a chain of stages, and each stage starts only when the one before it has finished. So one failure stops every stage after it. The last message on the screen points back to the stage that broke. This article gives you a map of the five stages, the typical failure at each one, and the commands that show the clues.

What you will learn

A chain breaks at one link

Each stage of the boot hands over to the next. A stage can start only when the one before it has finished its job.

So when one stage fails, the stages after it never run. The boot stops there, or drops into a small shell. The message on the last screen, or the place where the output stops, shows which stage failed. That is your first clue.

The five stages, in order

Finding the stage that broke

Start with the screen. Read the last message first, because it usually names the stage that failed.

Next, read the journal. It is systemd's log, and it can keep the messages of each boot when it is stored on disk.

Then name the stage first, and check the logs and settings for that stage only. Guessing across all the stages wastes time.

Reading the clues after a boot

Once the machine is up again, these commands show what went wrong. The first lists the failed units. The second shows the error messages from this boot. The third shows the same for the previous boot. The last shows the kernel's own recent errors and warnings.

Note: The previous boot is only available if the journal kept its messages.

Try it yourself

You need a shell on the Linux server after a failed boot. These four commands only read information, and they show the clues the boot left behind.

  1. List the units that failed during this boot.

    systemctl --failed

    What you should see: The units that failed during this boot. An empty list means none failed.

  2. Show only the error messages from this boot.

    journalctl -b -p err

    What you should see: Only the error messages from this boot.

  3. Show the error messages from the previous boot, if the journal kept them.

    journalctl -b -1 -p err

    What you should see: The same messages for the previous boot, if the journal kept it.

  4. Show the last kernel errors and warnings.

    dmesg --level=err,warn | tail -5

    What you should see: The last kernel errors and warnings, so you can see whether the disk driver complained.

Terms

Root disk
The disk that holds the system's files. The kernel must find it to finish the boot.
fstab
The file that lists the disks and folders that systemd attaches at boot.
Journal
systemd's log of messages. It can keep the messages of each boot when it is stored on disk.

Check yourself

Why do the stages after a failed one never run?

Each stage starts only when the one before it has finished, so a failed stage stops the chain there.

Where should you look first after a failed boot?

At the last message on the screen, which usually names the stage that failed. Then check the logs for that stage.

What does journalctl -b -p err show?

Only the error messages from this boot.

Previous: What systemd does at boot. Next: Process and thread: what is the difference?.