Linux Startup Taking Too Long? Chart It!

Hardware keeps getting faster and faster, and most of us are running machines that would have been unthinkably speedy a decade ago, yet somehow it never seems to feel that way. As the hardware gets faster, the software seems to get bigger and slower and we always seem to end up with something that dances around the line of usability. Linux has been no exception to this, with each new advance in hardware bringing a matching increase in the complexity of the software. If your system takes too long to boot, the best way to fix it is to know what’s bringing you down. For that, there’s Bootchart. This little utility will show you exactly what’s launching when and how long it each step takes.

Installation

Most major Linux distributions have Bootchart already available in their standard repositories. Ubuntu users, for example, could install through the Ubuntu Software Center or from the command line with:

sudo apt-get install bootchart

If your distro does not have a package available, you can get one from the Bootchart download page.

If you installed from source, you may need to manually add Bootchart to your system startup routine. If that’s the case, please see the documentation here.

Running Bootchart

If installed correctly, Bootchart does not need to be directly run by the user. Instead, it is loaded by the OS at boot time. Naturally, this means that you’ll have to reboot for Bootchart to do its thing. Reboot into whatever runlevel you wish Bootchart to monitor. If you don’t know what a runlevel is, just boot normally.

Once the system is back up and running, you can take a look at your chart (/var/bootchart) to find the problem areas.

bootchart-firstrun

It’s worth noting that a bar which runs the full width of the chart does not necessarily mean it’s slow. Often these are programs that are initiated during startup and continue to run once startup is complete, like udev or Xorg.

To get an idea how much time each item spends actually drawing heavy resources, take a look at the bar closely and you’ll see different shades of color representing the different states of the program at that time.

bootchart-detail

The blue sections represent time spent utilizing the CPU, the pink shows disk activity, and grey is time spent idle. If you’re looking for ways to prune your startup, look for items with a lot of blue or pink, as they’re eating up the most resources.

Removing Startup Items

This is where things can get tricky, as different Linux distributions sometimes handle startup in different ways. The “standard” method is known as SysV Init, and we’ve previously discussed startup modifications on Debian’s SysV style startup. This method will work on most Linux distributions.

In short, you’ll probably find the list of startup programs in a location such as /etc/rc2.d. Details of the removal process can be found at the link above, however there is one point that should be emphasized. The files you see in your rcX.d directory all follow a consistent naming scheme. Those starting with S are launched when that runlevel is reached, those starting with K are killed.

This means that to prevent an item from launching, you do not need to edit or remove the file, just rename it so that the S is now a K. This will ensure that the application is not run, and you can leave the files completely intact in case you decide to change your mind later.

Conclusion

With a tool like Bootchart, you can trim your system down to only the things you need, reducing delay and resource usage in the process. With Bootchart and the Window Maker desktop, this author has been able to get a 1.2 GHz Debian system to boot in under 20 seconds, while actively using only 2% of system RAM. You can’t fix it if you don’t know it’s broken, and Bootchart makes that easy.

Do you like what you read here?

Receive the latest update in your inbox.

Or connect with us: