Diagnosing slow startup sequences in Ubuntu servers and workstations often begins with systemd-analyze blame or systemd-analyze critical-chain. While these commands list the total duration consumed by individual systemd services, they offer limited insight into underlying hardware utilization during early boot phases. When high startup latency is caused by disk I/O contention, CPU scheduling bottlenecks, or background scripts saturating memory before systemd reaches default target states, static timing lists fail to reveal concurrent resource conflicts. The systemd-bootchart utility samples processor load, memory consumption, I/O wait times, and per-process activity from the moment the kernel mounts root storage through full desktop initialization, rendering detailed graphical Scalable Vector Graphics (SVG) charts.
Understanding How systemd-bootchart Works
Unlike standard user-space performance profilers that launch after the init system is already operational, systemd-bootchart is designed to execute as an alternative PID 1 init wrapper during system boot. When invoked by the kernel:
systemd-bootchartforks the actual/lib/systemd/systemdbinary into the background to proceed with normal startup.- Meanwhile, the bootchart process remains active in memory, sampling
/proc/stat,/proc/meminfo,/proc/diskstats, and/proc/[pid]/statat high frequency (typically every 20 to 50 milliseconds). - Once boot concludes—or after a pre-configured sampling duration elapses—bootchart collates all collected metrics and renders a comprehensive SVG timeline into
/run/log/or/var/log/.
Installing systemd-bootchart on Ubuntu
The bootchart daemon is packaged in the official Ubuntu universe repositories. Install it using apt:
sudo apt update
sudo apt install -y systemd-bootchart
Once installed, inspect the default configuration file located at /etc/systemd/bootchart.conf:
cat /etc/systemd/bootchart.conf
Configuring Sampling Parameters in bootchart.conf
You can fine-tune bootchart’s sampling window and resource tracking by authoring overrides in /etc/systemd/bootchart.conf or drop-in files:
sudo tee /etc/systemd/bootchart.conf << 'EOF'
[Bootchart]
# Frequency of samples per second (default is 25 Hz / 40 ms)
Samples=500
Frequency=25
# Log CPU, memory, and disk usage
Filter=no
Output=/var/log
PlotJiffies=yes
ScaleX=100
ScaleY=20
EOF
Key configuration directives:
Samples=500: Specifies the maximum number of samples before bootchart terminates sampling and writes the SVG graph (e.g. 500 samples at 25 Hz captures 20 seconds of boot telemetry).Filter=no: Ensures short-lived child processes and shell forks are plotted rather than suppressed.Output=/var/log: Dictates the destination directory where the rendered bootchart SVG is stored.
Enabling Bootchart Profiling via GRUB Kernel Command Line
To profile the next system startup, you must instruct the Linux kernel to execute systemd-bootchart as the initial process.
For a one-time profiling run without permanently editing GRUB configuration:
- Reboot your Ubuntu system:
sudo reboot. - At the GRUB boot menu, highlight the primary Ubuntu kernel entry and press e to edit kernel parameters.
- Locate the line beginning with
linux(orlinux64) that contains your root filesystem options. - Append the following parameter to the end of the line:
init=/lib/systemd/systemd-bootchart - Press Ctrl + X or F10 to boot with the bootchart wrapper active.
Alternatively, to enable bootchart logging across multiple reboots for ongoing optimization testing:
# Append parameter to GRUB default configuration
sudo sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="/GRUB_CMDLINE_LINUX_DEFAULT="init=\/lib\/systemd\/systemd-bootchart /' /etc/default/grub
sudo update-grub
Retrieving and Analyzing the Boot Performance SVG Chart
Once Ubuntu finishes booting and user services start, systemd-bootchart renders the collected timeline graph and writes it to disk:
# Check for generated bootchart SVG files
ls -lh /var/log/bootchart-*.svg /run/log/bootchart-*.svg 2>/dev/null
To inspect the chart, copy the SVG file to your local desktop workstation or open it directly in a web browser:
# Example: View file information
file /var/log/bootchart-*.svg
The rendered timeline contains three synchronized analytical panels:
- Top Panel (CPU & Wait States): Graphs aggregate CPU usage partitioned into user time, system time, and I/O wait (wa). A high I/O wait spike indicates that CPU cores were stalled waiting on disk throughput.
- Middle Panel (Memory & Disk Throughput): Tracks RAM allocation alongside write/read disk throughput in MB/s, revealing when swap or heavy storage churn occurred.
- Bottom Panel (Process Tree Timeline): Displays an exhaustive horizontal Gantt chart of every process executed during boot, ordered chronologically. It reveals exactly which background daemons (such as
cloud-init,snapd,systemd-networkd, orapt-daily) held locks and delayed the transition to target runlevels.
Cleaning Up and Disabling Permanent Boot Profiling
Because continuous sampling consumes CPU cycles during every startup, revert permanent GRUB parameters once your benchmarking is complete:
sudo sed -i 's/init=\/lib\/systemd\/systemd-bootchart //' /etc/default/grub
sudo update-grub
Profiling boot metrics with systemd-bootchart gives Ubuntu system administrators granular, visual telemetry that exposes root-cause startup bottlenecks and enables precise kernel optimization.