systemd-analyze — Boot Analysis

If you like this project, consider supporting me on Buy Me a Coffee ☕️


tags:

Description

systemd-analyze is a tool to analyze systemd boot performance, unit dependencies, and critical chain. Helps identify slow units and security issues. / systemd-analyze — инструмент анализа загрузки systemd, зависимостей unit-ов и критической цепочки. Помогает найти медленные unit-ы и проблемы безопасности.

Common use cases / Типовые сценарии:

Status: Built-in systemd utility. Alternatives: systemd-analyze plot, bootchart, dmesg. / Статус: встроена в systemd; альтернативы — plot, bootchart, dmesg.

Paths: unit files /etc/systemd/system/, /lib/systemd/system/.

Cross-reference: systemctl, journalctl, dmesg.


Core Management

Boot time / Время загрузки

systemd-analyze
systemd-analyze time
systemd-analyze blame
systemd-analyze critical-chain
systemd-analyze critical-chain multi-user.target

Plot / Построение графика

systemd-analyze plot > /tmp/boot-plot.svg
# Open in browser

Security audit / Аудит безопасности

systemd-analyze security
systemd-analyze security sshd.service
systemd-analyze security --no-pager | head -40

Sysadmin Operations

Dependencies / Зависимости

systemd-analyze dot --to-pattern="*.target" | dot -Tsvg > /tmp/deps.svg
systemd-analyze verify /etc/systemd/system/myservice.service
systemd-analyze cat-config

Compare boots / Сравнение загрузок

systemd-analyze time --history
# Or compare two boots via journal
journalctl -b -1 -o short-monotonic | head
journalctl -b -o short-monotonic | head

Troubleshooting

Symptom Cause Fix
Slow boot Slow unit at top of blame Optimize or disable unit
Missing dependency Broken Requires/After Fix unit file
Security score high Over-permissive unit Add sandboxing
verify fails Syntax error Fix unit file
systemd-analyze blame | head -20
systemd-analyze critical-chain
systemd-analyze verify <UNIT>

Comparison Tables

Boot analysis tools / Инструменты анализа загрузки

Tool Notes
systemd-analyze Built-in, precise
bootchart Visual history
dmesg Kernel messages
journalctl -b Full boot journal

Production Runbooks

Runbook: Optimize boot time / Оптимизация времени загрузки

  1. systemd-analyze blame — find slowest units / Найти медленные unit-ы
  2. Review critical-chain / Проверить critical-chain
  3. Disable unnecessary services / Отключить ненужные сервисы
  4. Delay non-critical units / Отложить некритичные unit-ы
  5. systemd-analyze verify fixed units / Проверить исправления
  6. Reboot and re-measure / Перезагрузить и замерить
  7. Document baseline boot time / Задокументировать базовый boot time

Runbook: Security hardening via analyze / Ужесточение через analyze

  1. systemd-analyze security — review score / Проверить score
  2. Focus on high-risk services / Сфокусироваться на рискованных
  3. Add ProtectSystem, PrivateTmp, NoNewPrivileges / Добавить sandboxing
  4. systemd-analyze security again — verify / Проверить снова
  5. Test service after hardening / Протестировать после hardening
  6. Document changes / Задокументировать изменения

On this page

linux 📊 systemd-analyze Cheatsheet Description Core Management Boot time / Время загрузки Plot / Построение графика Security audit / Аудит безопасности Sysadmin Operations Dependencies / Зависимости Compare boots / Сравнение загрузок Troubleshooting Comparison Tables Boot analysis tools / Инструменты анализа загрузки Production Runbooks Runbook: Optimize boot time / Оптимизация времени загрузки Runbook: Security hardening via analyze / Ужесточение через analyze Documentation Links