Linucate
~ Linucate_

101.2 Boot the system

All Levels

Introduction

This lesson answers a very practical question:

What happens from pressing the power button to getting a working Linux system?

For LPIC-1, you should understand the boot path and know where to look when boot fails.

Keep this simple picture in your head:

firmware -> bootloader -> kernel -> initramfs -> real root filesystem -> PID 1 -> login

If you know that order, you can usually tell where a problem belongs.

What you should be able to do after this lesson:

  • Explain the Linux boot sequence in simple words.
  • Check whether the system used BIOS or UEFI.
  • Read the current kernel command line.
  • Make a temporary boot change in GRUB.
  • Recognize what initramfs does.
  • Check boot messages and common failure clues.

Before you start:

  • sudo means "run as administrator".
  • <kernel-param>, <entry>, <device> are placeholders. Replace them with real values.
  • Different distributions store GRUB files in different paths. Focus on the idea first.

Big Picture: The Boot Sequence

When Linux boots, the system usually moves through these steps:

  1. Firmware starts first. This is BIOS or UEFI.
  2. Bootloader starts next. Most often this is GRUB 2.
  3. Kernel is loaded. The kernel begins hardware setup.
  4. initramfs helps early boot. It gives the kernel a temporary working environment in RAM.
  5. The real root filesystem is mounted.
  6. PID 1 starts. This is usually systemd, but it could also be another init system.
  7. Services start, then you get a login prompt or desktop.

That is the story the exam wants you to understand.

Step 1: Firmware (BIOS or UEFI)

Firmware decides where boot starts.

Quick check

test -d /sys/firmware/efi && echo UEFI || echo BIOS

What is the difference?

BIOS

  • older style firmware
  • usually boots from the MBR area of a disk

UEFI

  • modern firmware
  • uses boot entries stored in NVRAM
  • starts EFI programs from the EFI System Partition (ESP)

Optional UEFI check

If efibootmgr is installed:

sudo efibootmgr -v | head

This shows saved UEFI boot entries.

Step 2: Bootloader (Usually GRUB 2)

The bootloader's job is simple:

load a kernel, load an initramfs, and pass kernel parameters

Read the kernel command line used for this boot

cat /proc/cmdline

Example output:

BOOT_IMAGE=/boot/vmlinuz-6.1.0 root=UUID=xxxx ro quiet

Important parameters to recognize

  • root=... = where the root filesystem is
  • ro = mount root read-only first
  • rw = mount root read-write
  • quiet = show fewer messages during boot

Useful troubleshooting parameters

  • systemd.unit=rescue.target = boot into rescue mode on systemd systems
  • nomodeset = often used for display problems
  • single or 1 = old-style single-user boot idea you may still see in exam material

Temporary GRUB Edit: Safe and Important

For the exam, this is one of the most useful boot skills.

Typical flow

  1. Open the GRUB menu.
  2. Select an entry.
  3. Press e to edit it.
  4. Find the line that starts with linux or sometimes linuxefi.
  5. Add a temporary <kernel-param> at the end of that line.
  6. Boot with Ctrl+x or F10.

Why this matters:

  • it helps you test a fix
  • it does not permanently change files on disk

GRUB Command Line: Basic Commands to Recognize

Sometimes GRUB itself becomes part of the troubleshooting process. From the GRUB menu, you can press c to open the GRUB command line.

Commands to know:

ls
ls (<device>)/
set root=(<device>)
linux /vmlinuz root=...
initrd /initrd.img
boot

In plain words:

  • ls helps you discover disks and files
  • set root=... tells GRUB where to look
  • linux ... loads the kernel
  • initrd ... loads the initramfs
  • boot starts the boot process

Persistent GRUB Changes

Temporary changes are safer for testing. Persistent changes are for "I know this is the setting I want".

The usual place is:

/etc/default/grub

Typical variables:

  • GRUB_CMDLINE_LINUX=...
  • GRUB_CMDLINE_LINUX_DEFAULT=...

Then regenerate the GRUB configuration. Common commands:

sudo update-grub
sudo grub-mkconfig -o <grub.cfg>
sudo grub2-mkconfig -o <grub.cfg>

Different distributions use different commands. The key exam idea is:

edit GRUB defaults -> rebuild GRUB config

Step 3: Kernel and initramfs

The kernel starts hardware initialization. But very early in boot, it may not yet know how to reach the real root filesystem.

That is why initramfs exists.

In simple words

initramfs is a temporary mini-filesystem in RAM. It helps Linux do early jobs such as:

  • load storage drivers
  • find the root filesystem
  • prepare RAID, LVM, or encrypted disks

Quick check

ls -1 /boot | head -n 12
uname -r

Example output:

vmlinuz-6.1.0
initrd.img-6.1.0
6.1.0

What this tells you:

  • which kernel is installed
  • which initramfs image matches it
  • which kernel is currently running

Step 4: PID 1 and the Init System

After the kernel switches to the real root filesystem, it starts PID 1. PID 1 controls the rest of the startup process.

Quick check

ps -p 1 -o comm=

Possible results:

  • systemd = the modern default on most distributions
  • init = often a classic init name; on older systems this may mean SysVinit or an Upstart-based setup

For this lesson, the important point is simple:

the kernel gets the system started, then PID 1 takes over

The next lesson goes deeper into runlevels, targets, shutdown, and reboot.

Boot Logs: Where to Look First

When boot goes wrong, logs are your map.

1) Kernel messages

dmesg | tail -n 20
journalctl -k -b --no-pager | tail -n 20

Use this when you want to see:

  • hardware detection
  • driver errors
  • storage problems

2) Messages from the current boot

journalctl -b --no-pager | tail -n 20

Use this when you want the whole story of the current boot.

3) Only errors from this boot

journalctl -b -p err..alert --no-pager | head

4) Previous boot

journalctl --list-boots | head
journalctl -b -1 --no-pager | tail -n 20

This is very useful when the system booted badly before, but is working now.

Common Boot Failure Clues

You do not need to memorize every error message. You need to connect the message to the correct boot stage.

Wrong root filesystem

Message style:

ALERT! /dev/sda3 does not exist...

Common meaning:

  • wrong root= parameter
  • wrong disk name or UUID
  • needed storage driver missing in initramfs

Kernel boots, but cannot reach the real system

Common meaning:

  • broken or missing initramfs
  • storage stack not ready
  • RAID/LVM/encryption support missing early in boot

Black screen or video issue

Common meaning:

  • graphics mode problem
  • temporary test parameter: nomodeset

Quick Recovery Mindset

If the system does not boot cleanly, think in this order:

  1. Did firmware start the correct disk?
  2. Did GRUB load the kernel?
  3. Did the kernel get the right root= value?
  4. Did initramfs have what it needed?
  5. What do dmesg and journalctl say?

That order is often more important than remembering ten extra commands.

Practice Step by Step

1) Check what kernel parameters are active right now
  1. Run: cat /proc/cmdline
  2. Find: root=, ro or rw, quiet
  3. Ask: does the active boot match what I expected?
2) Simulate a safe troubleshooting change in GRUB
  1. Open the GRUB menu.
  2. Press e on an entry.
  3. Add a temporary parameter such as nomodeset or systemd.unit=rescue.target.
  4. Boot it once with Ctrl+x or F10.
  5. After a reboot, the change should be gone because it was temporary.
3) The system booted, but something is broken right after login
  1. Check current boot messages: journalctl -b -p err..alert --no-pager | head
  2. Check kernel messages: journalctl -k -b --no-pager | tail -n 50
  3. If the problem looks like hardware, compare with lesson 101.1 tools such as: lspci -nnk, lsusb -t, lsblk

Cheat Sheet

  • test -d /sys/firmware/efi && echo UEFI || echo BIOS = firmware mode check
  • efibootmgr -v = show UEFI boot entries
  • /proc/cmdline = kernel command line used for this boot
  • GRUB temporary edit = e, add parameter, boot with Ctrl+x or F10
  • GRUB command line = c, then use ls, set root=..., linux ..., initrd ..., boot
  • /etc/default/grub = common place for persistent GRUB defaults
  • update-grub / grub-mkconfig / grub2-mkconfig = rebuild GRUB config
  • /boot = common location for kernel and initramfs files
  • uname -r = current running kernel version
  • ps -p 1 -o comm= = identify PID 1
  • dmesg = kernel messages
  • journalctl -b = logs from the current boot
  • journalctl -k -b = kernel messages from the current boot
  • journalctl -b -1 = previous boot logs
🎯

Test Your Knowledge

Complete the quiz to assess your understanding of this course's concepts.