Question : My system is taking a lot of time to boot. How can I find out which services are taking long time to start?
systemd-analyze command can be utilized to find out information about how much each service took to start.
# systemd-analyze time Startup finished in 1.267s (kernel) + 6.798s (initrd) + 1min 2.139s (userspace) = 1min 10.205s
To find out, how much time each unit took to start, run systemd-analyze blame.
# systemd-analyze blame 24.728s dev-mapper-centos\x2droot.device 15.135s kdump.service 14.670s plymouth-quit-wait.service 14.210s firewalld.service 9.835s accounts-daemon.service 7.383s ModemManager.service 7.259s libvirtd.service 7.257s systemd-logind.service 7.177s ksm.service 7.081s gssproxy.service 7.067s avahi-daemon.service 7.062s rsyslog.service 7.039s abrt-ccpp.service
As you see the output is sorted according to the time taken by each unit, you can easily find out which service is taking more time during booting and can dig down deeper to analyze the issue.
At certain steps, the boot cannot proceed until all dependencies for unit are satisfied. To see units at these critical points run systemd-analyze critical-chain.
# systemd-analyze critical-chain The time after the unit is active or started is printed after the "@" character. The time the unit takes to start is printed after the "+" character. graphical.target @1min 2.102s └─multi-user.target @1min 2.102s └─abrt-vmcore.service @1min 1.228s +872ms └─kdump.service @46.090s +15.135s └─remote-fs.target @46.086s └─remote-fs-pre.target @46.083s └─iscsi-shutdown.service @45.951s +99ms └─network.target @45.944s └─network.service @44.959s +975ms └─NetworkManager.service @38.653s +689ms └─firewalld.service @24.439s +14.210s └─basic.target @23.850s └─sockets.target @23.849s └─cups.socket @23.847s └─sysinit.target @23.618s └─systemd-update-utmp.service @23.603s +13ms └─auditd.service @22.959s +643ms └─systemd-tmpfiles-setup.service @22.726s +230ms └─rhel-import-state.service @22.431s +294ms └─local-fs.target @22.428s └─boot.mount @19.675s +2.126s └─dev-disk-by\x2duuid-7de2053c\x2d44d7\x2d4f33\x2db522\x2d81dee2f6b69b.device @19.652s
SVG graphic image can be plot which contains detailing about system services start time, highlighting the time they spent on initialization. Make sure you have enabled graphical display mode or have x-windows enabled in order to see the plot.
# systemd-analyze plot > plot.svg # eog plot.svg
Here is a snip from sample plot on my CentOS 7 machine. Zoom in to check the waterfall clearly.