ubuntu, updated

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?

WhatCommand
Services sorted by start timesystemd-analyze blame
The chain that actually delayed the bootsystemd-analyze critical-chain
Chain for one unitsystemd-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 unitCauseFix
systemd-networkd-wait-online.service (often 2 minutes)Waits for all interfaces, also unplugged or unconfigured onesMark extra interfaces optional: true in Netplan
cloud-init*.serviceLooks for a cloud data source on a non-cloud VMsudo touch /etc/cloud/cloud-init.disabled if you don’t use cloud-init
snapd.seeded.serviceFirst boot or snap refreshUsually one-time; remove snaps you don’t need
apt-daily*.servicePackage list update at bootNormal, runs in the background
A mount (*.mount) or dev-*.device timing outDisk in /etc/fstab missingFix fstab, add nofail (Format and mount)
    ens19:
      optional: true      # don't wait for this interface at boot

Check for errors

WhatCommand
Failed unitssystemctl --failed
Errors of this bootjournalctl -b -p err
Check a unit file for mistakessystemd-analyze verify /etc/systemd/system/myapp.service
Security score of a service (lower is better)systemd-analyze security nginx.service
Overview of all services’ securitysystemd-analyze security
Validate a calendar expression (timers)systemd-analyze calendar "Mon..Fri 06:00"
Time zone and clocktimedatectl

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.

§ home
~/knubertus/home/
1,1 Top