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 How to Build an Amazon Price Tracking Bot to know Price Drops

About author

You might also like

Linux Topics 0 Comments

How to Copy Directory in Linux / Unix

If you are looking to copy a directory in Linux using a command line, then here I have explained what command to use to copy a folder in Linux or

Linux Topics 0 Comments

How to Configure Sudo to run Without Password or Password-less

If you are using a Linux system in your home which does not need much security or you know there is no threat if you allow to run the sudo

Linux Topics 0 Comments

How To Use dd command In Linux/Unix To Make USB Bootable?

DD command is used to create a bootable disk from an existing image as it clones data from one disk or partition (or a disk image) to other at the

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply