Znalostní báze
simpu.net/support > simpu.net support helpdesk > Znalostní báze

Improving boot times

Řešení

Improving boot times

 

Getting-up-and-running-faster asks: Is there is a tool which shows the services that are slowing down boot time? How can I find stalled processes and speed up my boot times? 

DistroWatch answers: There are methods for discovering which processes are slowing down the boot process. Most distributions these days run the systemd init software and, assuming your distribution uses systemd, there is a special utility for analyzing the boot process and the time services take to start-up. To confirm your distribution uses systemd, run the following command in a terminal, it will let you know whether your operating system is running systemd.

grep systemd /proc/1/comm && echo I am using systemd || echo I am not using systemd

Distributions using systemd can run the following command to see which processes start at boot time and how long each takes to get up and running:

systemd-analyze blame

The output will be a list of start-up services, sorted in order by how much time they take to get up and running. It may look like this:

14.732s networkd-dispatcher.service
2.887s systemd-logind.service
2.874s snapd.service
2.859s wpa_supplicant.service
2.839s rsyslog.service
2.788s lm-sensors.service
2.416s polkit.service
1.392s systemd-sysusers.service
1.377s systemd-resolved.service
1.077s lightdm.service

The systemd-analyze program can also show bottlenecks in start-up performance. The following command shows services starting up with indicators of at what time they started and how long they took to start:

systemd-analyze critical-chain

The output from the critical chain parameter may look like this:

multi-user.target @32.439s
 - networkd-dispatcher.service @17.696 +14.732s
    - basic.target @17.652s
      - sockets.target @17.651s

The numbers after the "@" symbol show when the target was reached and the number after the "+" shows how long a service took to start. In the above examples we can see that the networkd-dispatcher service is taking an unusually long time (14.7 seconds) to start, which is roughly half the total boot time. We may need to fix its configuration or figure out why it is taking so long to complete its tasks. 

Alternatively, we might want to start networkd-dispatcher sooner rather than when it is needed. systemd can start background services either when they are needed (on demand) or in parallel. Enabling a background service which takes longer to boot can get it started sooner and possibly reduce the overall boot time. We can enable a service as follows:

systemctl enable networkd-dispatcher

In my case networkd-dispatcher was already enabled so this would not improve my boot times. Another way to go is to disable a service we do not need from the start-up process. Basically turning off services we do not use. For instance, I do not think I will need networkd-dispatcher so I can turn it off with the following command:

systemctl disable networkd-dispatcher

I then rebooted and re-ran the "systemd-analyze critical-chain" command and found my boot times improved by six seconds. Here is my list of start-up services with the problematic program disabled:

multi-user.target @26.031s
  - kerneloops.service 26.031s +247ms
    - network-online.target @25.989s

Basically, one of the easiest ways to improve boot times is to figure out which services are running that we do not need and disable them, or uninstall them. The systemd-analyze utility is great at identifying not only which services start, but which ones are causing the most delays. 

While the above options work with distributions running systemd, should we find ourselves using a distribution that runs another implementation of init, such as SysV init, then we can look for clues as to what is slowing down the boot process in the /var/log/boot log file. The log file is more crude than systemd's analyzing utility, but it will show when services are starting. Since SysV init services tend to start in groups, seeing gaps in service start times will tell us which group of services are slowing down the process. For instance, in the following log entries we can see a long gap (three seconds) between two services starting, which suggests a bottleneck:

Fri Apr 26 10:25:20 2019: [....] CPUFreq Utilities: Setting ondemand CPUFreq governor...CPU0...CPU1... ok
Fri Apr 26 10:25:21 2019: [....] Starting network connection manager: NetworkManager ok 
Fri Apr 26 10:25:24 2019: [....] Starting NetBIOS name server: nmbd ok

Once again, we can look at either improving the service's configuration or disabling it from starting at boot time. 

For people running spinning hard drives, if the necessary resources are available, one of the easiest ways to improve boot times is by switching to using a solid state drive (SSD). SSDs are better at reading small, randomly placed files which tends to improve start-up times.

 

source: https://distrowatch.com/weekly.php?issue=20190610
 
Byl tento příspěvek užitečný? ano / ne
Podobné příspěvky Manjaro - Multiboot GRUB2 corrupt
Podrobnosti
Příspěvek č.: 12
Kategorie: Linux
Datum vložení: 2019-06-10 10:42:10
Počet zobrazení: 19
Hodnocení (počet hlasů): Příspěvek zatím nebyl hodnocen (0)

 
« Zpět

 
Powered by Help Desk Software HESK, in partnership with SysAid Technologies