Kahibaro
Discord Login Register

3.5.4 Boot performance

Understanding Boot Performance

Boot performance focuses on how fast (and reliably) a system goes from power-on to a usable login prompt or desktop. In this chapter, you’ll learn how to:

Low boot time is not just for desktops and laptops; on servers, slow boot can delay maintenance windows and lengthen recovery times after outages.

This chapter assumes you already understand basic systemd concepts and log viewing from earlier chapters in this part.


Key Boot Stages That Impact Performance

Without re-teaching the entire boot process, it’s useful to know which stages typically matter for performance tuning:

  1. Firmware (BIOS/UEFI)
    • Hardware initialization and self‑tests
    • Disk/boot device enumeration
    • Bootloader selection
  2. Bootloader (e.g., GRUB2)
    • Menu display and timeout
    • Loading kernel and initramfs
  3. Kernel + initramfs
    • Hardware/driver initialization
    • Root filesystem discovery and mounting
    • Switching from initramfs to real root
  4. Init system (systemd)
    • Starting essential system services
    • Activating sockets, devices, mounts, targets
    • Reaching multi‑user or graphical targets

Most of your tuning effort in a modern Linux system focuses on:

Firmware and kernel-level improvements are possible but more limited.


Measuring Boot Time

Before optimizing, measure where time is spent. On systemd-based systems, the main tools are:

Total Boot Time with `systemd-analyze`

Run:

systemd-analyze

Example output:

Startup finished in 3.150s (firmware) + 1.982s (loader) + 4.687s (kernel) + 12.345s (userspace) = 22.164s 
graphical.target reached after 12.100s in userspace.

Interpretation:

Actionable parts for a typical admin:

Measuring Per-Service Time: `systemd-analyze blame`

Run:

systemd-analyze blame

Example:

10.222s NetworkManager-wait-online.service
5.023s docker.service
3.112s snapd.service
1.701s plymouth-quit-wait.service
1.320s dev-sda2.device
...

This shows how long each unit took to start. Look for:

Note: blame is approximate and does not show dependency relationships, only durations.

Visualizing the Critical Path: `systemd-analyze critical-chain`

Run:

systemd-analyze critical-chain

Example (abridged):

graphical.target @12.100s
└─multi-user.target @12.099s
  └─network-online.target @12.098s
    └─NetworkManager-wait-online.service @1.876s +10.222s
      └─NetworkManager.service @0.800s +1.075s
        └─basic.target @0.750s
          └─sockets.target @0.749s
            └─snapd.socket @0.740s +5ms
...

Interpretation:

Use critical-chain to focus on items that are on the critical path rather than just “slow in isolation.”

Boot Charts and Graphs

Many distributions support a graphical view:

systemd-analyze plot > boot.svg

Open boot.svg in a browser or image viewer.

This helps identify:

Using Logs to Investigate Slow Boots

System logs provide timing and error context beyond systemd-analyze.

Viewing Logs for the Current Boot

Use:

journalctl -b

This shows logs starting from the current boot. To focus on boot timing:

journalctl -b -g "Started "
journalctl -b -p warning

Viewing Logs for Previous Boots

Each boot has an index:

journalctl --list-boots

Example:

-1 1f2e3d4c5b6a4e3d8c9f0a1b2c3d4e5f Mon 2025-11-03 10:00:00 UTC—Mon 2025-11-03 10:05:00 UTC
 0 a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6 Mon 2025-11-03 15:15:00 UTC—Mon 2025-11-03 15:18:00 UTC

Then:

journalctl -b -1

This is useful if users report “sometimes the system boots very slowly” — you can compare logs from a slow boot to a normal one.


Common Boot Bottlenecks

Boot slowdowns often fall into recurring categories. Here are the main ones and how to spot them.

Network Initialization Delays

One of the most frequent causes of slow boot is waiting for network connectivity.

Typical symptoms:

These units block further services until the network is “up.” On servers, this might be necessary; on desktops or laptops, it often isn’t.

Options to Improve

  sudo systemctl disable NetworkManager-wait-online.service
  # or
  sudo systemctl mask NetworkManager-wait-online.service

Only do this if no critical services depend on the network being fully online at boot.

Always test changes with:

sudo systemctl reboot
systemd-analyze
systemd-analyze critical-chain

Filesystem and Mount Issues

Another common delay: the system waits for filesystems or network shares that are slow or unavailable.

Symptoms:

To investigate:

systemctl list-units --type=mount
journalctl -b -u mnt-backup.mount

Ways to improve:

Example /etc/fstab entry with systemd options:

server:/export /mnt/nfs nfs defaults,noauto,x-systemd.automount,x-systemd.device-timeout=10 0 0

This prevents the entire boot from being stalled by a slow NFS server.

Graphical Boot and Display Managers

Display managers and graphical stacks can add noticeable time.

Symptoms:

Options:

    sudo systemctl set-default multi-user.target

Hardware Probing and Firmware

Some delays are outside the OS’s direct control:

You usually see these in systemd-analyze as large firmware or kernel times.

Limited options:

Third-Party and Optional Services

Applications that install their own system services can slow boot.

Identify:

Adjust:

  sudo systemctl disable SERVICE_NAME
  # or
  sudo systemctl mask SERVICE_NAME

Always confirm you are not disabling something essential. Test by rebooting and verifying system functionality.


Tuning Systemd Startup Behavior

systemd offers several mechanisms that influence boot performance.

Parallelization and Dependencies

By default, systemd runs units in parallel as long as dependencies allow it. Unnecessary dependencies can serialize startup and slow things down.

To analyze dependencies for a unit:

systemctl list-dependencies NAME.service
systemctl list-dependencies --reverse NAME.service

Look for:

You can override dependencies without editing the original unit files by using drop-ins.

Using Drop-in Overrides

To modify a unit safely:

sudo systemctl edit NAME.service

This opens an editor with a fragment like:

[Service]
# Your overrides here

Or to adjust dependencies:

[Unit]
After=network.target
Wants=network.target
# Remove network-online.target if not needed:
# After=
# Wants=

Save and reload:

sudo systemctl daemon-reload

Then reboot and re-measure. Be conservative: incorrect dependency changes can cause services to start before their requirements are truly ready.

Service Timeouts

Some services might wait a long time when something goes wrong. You can tune or cap this behavior.

For a specific unit:

  systemctl show NAME.service -p TimeoutStartUSec
  sudo systemctl edit NAME.service

Example:

  [Service]
  TimeoutStartSec=30

This ensures that if the service cannot start within 30 seconds, systemd moves on. Make sure the service can tolerate being stopped or failed earlier.

Delayed or On-Demand Services

Some services do not need to start at boot; they can be activated when first used.

Typical usage depends on their unit definitions and your distribution; I/O-heavy or rarely used daemons are good candidates to be started on demand.


Reducing Perceived Boot Time

Perceived boot time is “how long until the system feels ready to use,” which is slightly different from measured boot completion.

Ways to improve user perception:

Even if systemd reports 20 seconds to graphical.target, users may not notice if the system is responsive quickly after the login screen.


Monitoring Boot Performance Over Time

Once tuned, keep an eye on boot speed so regressions don’t go unnoticed.

Ideas:

  systemd-analyze >> /var/log/boot-times.log

via a simple root cron job or systemd timer.

This is especially important on critical servers where boot time matters during maintenance windows or failover scenarios.


Practical Boot Tuning Workflow

A typical sequence for improving boot performance:

  1. Measure baseline
    • systemd-analyze
    • systemd-analyze blame
    • systemd-analyze critical-chain
  2. Identify obvious bottlenecks
    • Network “wait-online” services
    • Slow mounts or failing devices
    • Bulky third‑party services
  3. Review logs
    • journalctl -b for timeouts, errors, and long gaps
  4. Apply targeted changes
    • Disable/mask unnecessary services
    • Fix or mark optional mounts
    • Adjust timeouts or dependencies with drop-ins
    • (If needed) tweak bootloader timeouts or firmware settings
  5. Reboot and validate
    • Confirm system functions as required
    • Re-run systemd-analyze and compare
    • Monitor for a few cycles to ensure stability

Working iteratively like this avoids breaking dependencies and keeps changes auditable.


By understanding where time is spent and using systemd’s analysis tools, you can systematically improve both real and perceived boot performance, making systems more responsive and reducing downtime after reboots.

Views: 72

Comments

Please login to add a comment.

Don't have an account? Register now!