Have you ever wondered how much time it takes for your system to boot? Maybe someone you know has claimed that their system boots faster than yours and you're curious about the exact time. While not everyone is interested in the numbers, you might be. You'll certainly want booting to be as fast as possible.
By the end of this guide, you'll have a brief understanding of what affects your Linux system's boot time and how to calculate its total duration. You'll also learn ways to decrease the boot-up time and transform your computer into a fast and responsive beast.
How to Check Linux Boot Time Using systemd-analyze
Systemd is the default service manager that comes pre-installed on most Linux distributions. Using the systemd-analyze command, you can get detailed statistics about your system's previous boot-up. You can also see a breakdown of the services and find out the time taken by each one during boot.
To check the boot time using systemd-analyze, type:
The system will display output containing the total boot-up time. It also shows the time taken by the kernel and the userspace separately.
In this example output, you can see that it took approximately nine seconds for the machine to boot. Since the above image is of a virtual machine, its boot-up time might be faster than a normal Linux installation.
To get information on the time taken by each service during boot, use the blame method of systemd-analyze:
This will produce output that looks a bit like the following:
As you can see, the output displays a list of all the services and the time taken by each.
What Affects the Linux Boot Time?
When you start your Linux system, the BIOS is the first thing that loads. The BIOS then transfers control to the MBR (master boot record), which starts the GRUB bootloader. GRUB is responsible for loading the kernel, which further sets up the initial root filesystem and executes the init process. Then the execution of other services takes place.
The time taken by these other services accounts for the largest share of your system's boot time. The more services you have during startup, the longer it will take to boot your system. Therefore, stopping unnecessary services from running during startup is important if you want your system to boot faster.
How to Fix a Slow Booting Linux Machine
You can't stop the init process or the GRUB bootloader from starting during boot-up, as it will cause issues with your system's boot-up sequence. However, you can disable unimportant services on your system so they don't run during startup.
The systemctl utility allows you to manage services on Linux. Using the tool, you can easily start and stop services. But first, let's get a reminder of which services started during the last boot:
In this output, you can see that the exim4-base.service is taking the highest share of the boot time (around three seconds). Exim4 is a mail-transport agent and exim4-base is the service that provides necessary support files required by the exim4 daemon.
Since it's not an important service for a local system, you can disable it using systemctl to save some time during bootup:
sudo systemctl disable exim4-base.service
Note: If you're not totally sure what you're doing, you should check with an experienced Linux user before disabling any services. Disabling a critical service can cause unexpected problems with the OS.
To enable a service again, simply replace disable with enable in the systemctl command:
sudo systemctl enable exim4-base.service
Using this process, you can tweak the services that your system starts to decrease boot time.
Improving Linux Boot Time Without Any Hardware Changes
While many will suggest installing Linux on an SSD to improve boot time, you can do it free of cost by disabling unwanted services on your system. Although it won't decrease the startup time drastically, every second counts if you want a computer with swift performance.
Fancy a fast and responsive system? Installing a lightweight and minimal Linux distribution on your PC can help.