How to Find and Reduce Boot Time in Linux
This post was last updated on August 1st, 2020 at 10:36 pm
When you power on a Linux system it initializes different services and runs different processes. The whole process can take some time that may vary from a few seconds to a few minutes. If the system takes unreasonably more time to boot then it is crucial to find out which process takes much time and fix it.
Ahead in this article, we will see how can we know the exact time taken in booting and how can you analyze it to optimize the system’s boot time.
How to Find boot time with systemd-analyze?
Systemd is a newer init system in Linux that includes various features like on-demand starting daemons, snapshot support, process tracking, and inhibitor locks, etc. It provides a number of utilities that can be used to manage a Linux operating system.
systemd-analyze is one of the systemd utilities command available in a Linux system that helps tracking down the process execution time.
Use the following command to see the details of services run at the last startup and it also displays the time taken by them –
As you can see in the image above my system takes approximately 46.335s to boot out of which the userland processes itself took 38 seconds.
Using systemd-analyze blame
You can use the following command to further breakdown this boot time into each unit by the process. Execute this command in the terminal –
Now, look at the output of this command –
The services are printed in decreasing order of the time taken while booting.
How to improve boot time in Linux?
The most important part of reducing the boot time is to find which process is taking more time. As discussed above after executing the systemd-analyze blame command you can find the services that are taking more than expected time. If a service is not necessary for the operating system you can disable it also. It will decrease the overall boot time of the system.
So, disabling the service which takes more time in the booting process will help to reduce the overall boot time of a Linux machine. From the above output –
NetworkManager-wait-online.service are two services that are taking the maximum time. In some multi-user environments, part of the boot-up process can come from the network.
For this case
systemd defaults to waiting for the network to come on-line before certain steps are taken. It is possible that a user waits for an extremely long time for the network so the recommendation for this is to set the maximum wait time to 30s or a better way is to simply disable it. Disabling the Network Manager will not affect the core functionality of the operating system but if it is a different process then you need to assess it carefully before disabling. By using the following command you can disable a service in Linux –
sudo systemctl disable service-name sudo systemctl disable NetworkManager-wait-online.service
And whenever you need you can enable it back again by using the following command –
sudo systemctl enable service-name sudo systemctl enable NetworkManager-wait-online.service
Well, that is all on reducing and optimizing the boot time on Linux. If you have a query or suggestion regarding this topic, you can write to us in the comments below.
You might also like
The Emacs or GNU emacs is one of the oldest and feature-rich text editor. Initially, it was developed for the Unix-like operating systems but later released for Windows and such
This post was last updated on August 1st, 2020 at 01:28 pmA software repository is a database of software packages stored on a remote server. Generally, these packages are retrieved
This post was last updated on August 3rd, 2020 at 03:06 pmA process is an instance of a computer program that is currently running. A program can have multiple instances