Slow boot? systemd-analyze
Find out how long the server takes to boot, which services slow it down, and check unit files and the system for errors.
How long did the boot take?
systemd-analyze
Startup finished in 3.1s (kernel) + 41.8s (userspace) = 44.9s
multi-user.target reached after 41.6s in userspace.
kernel is the kernel itself, userspace is everything systemd starts. Physical servers also show firmware and loader (BIOS/UEFI and GRUB). A VM server usually boots in 10 to 30 seconds; much more is worth a look.
Who is slow?
| What | Command |
|---|---|
| Services sorted by start time | systemd-analyze blame |
| The chain that actually delayed the boot | systemd-analyze critical-chain |
| Chain for one unit | systemd-analyze critical-chain nginx.service |
| Graphical timeline (open in a browser) | systemd-analyze plot > boot.svg |
blame lists every service by time, but services start in parallel, so a slow one doesn’t always delay the boot. critical-chain shows what really held things up: the time after @ is when the unit was started, after + how long it took.
Usual suspects
| Slow unit | Cause | Fix |
|---|---|---|
systemd-networkd-wait-online.service (often 2 minutes) | Waits for all interfaces, also unplugged or unconfigured ones | Mark extra interfaces optional: true in Netplan |
cloud-init*.service | Looks for a cloud data source on a non-cloud VM | sudo touch /etc/cloud/cloud-init.disabled if you don’t use cloud-init |
snapd.seeded.service | First boot or snap refresh | Usually one-time; remove snaps you don’t need |
apt-daily*.service | Package list update at boot | Normal, runs in the background |
A mount (*.mount) or dev-*.device timing out | Disk in /etc/fstab missing | Fix fstab, add nofail (Format and mount) |
ens19:
optional: true # don't wait for this interface at boot
Check for errors
| What | Command |
|---|---|
| Failed units | systemctl --failed |
| Errors of this boot | journalctl -b -p err |
| Check a unit file for mistakes | systemd-analyze verify /etc/systemd/system/myapp.service |
| Security score of a service (lower is better) | systemd-analyze security nginx.service |
| Overview of all services’ security | systemd-analyze security |
| Validate a calendar expression (timers) | systemd-analyze calendar "Mon..Fri 06:00" |
| Time zone and clock | timedatectl |
Boot didn’t finish at all
If the server drops into emergency mode, it’s almost always /etc/fstab (a missing disk or a typo). Log in with the root password (or boot with recovery mode from GRUB), then:
journalctl -xb | less # look for the first red lines
nano /etc/fstab # fix or comment out the line, add nofail
systemctl daemon-reload && mount -a
reboot
Previous boots are in the journal too, see journalctl extras.