How to Find and Reduce Boot Time in Linux

How to Find and Reduce Boot Time in Linux

   

When you power on a Linux system it initializes different services and run different processes. The whole process can take some time that may vary from a few seconds to 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 –

systemd-analyze

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 process. Execute this command in the terminal –

systemd-analyze blame

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 in reducing the boot time of a Linux system. Just finding the process that takes much time to boot is not helpful in any way if we cannot reduce the boot time.

As discussed above after executing the systemd-analyze blame command 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 – apt-daily-upgrade.service and 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

WARNING:
Don’t disable any service that is necessary for the core functionality of the Linux operating system or until you don’t know about the consequences of it.

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.

Previous How to Configure Sudo to run Without Password or Password-less
Next What Is Git And How To Use It In Linux/Unix?

About author

You might also like

Linux Topics 0 Comments

How to Print files in Linux Using Command Line

Printing a file is one of the basic functionalities provide by the linux operating system, rather than just printing a file its provides us with a variety of options like

Linux Topics 0 Comments

What Is aptitude And How To Use It?

This post was last updated on January 31st, 2020 at 04:02 pmI already discussed briefly about Aptitude which is a debian package manager. In this article, we will see it

Linux Topics 0 Comments

How to Unload or Blacklist Module in Linux

This post was last updated on January 22nd, 2019 at 11:06 amSometimes you need to unload a kernel module to load your own written code or you want to replace

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply