Ubuntu Tips – Boot Faster

Last Updated on July 7, 2019

With the amazing feats performed by Linux kernel developers over the years, you might be tempted to think that systems installed with the latest Ubuntu distribution are already running at the fastest possible speed. However, this is often not the case. Ubuntu’s developers, Canonical, have to appeal to a wide audience, and ensure that their distribution runs with a diverse set of hardware. This has the unfortunate consequence that systems are not always fully optimised.

How important the length of time a system takes to boot largely depends on the function it performs. For example, fast bootup times are inconsequential to a system administrator who reboots a server infrequently. However, desktop users typically do not leave their computer running constantly. To be productive, desktop users need to be up and running as quickly as possible. A slow boot can be very annoying for them especially if they only want to catch up with email or check the latest sporting results, before dashing out the door.

There are some hardware solutions that provide an ‘Instant-On’ function, where the time to boot can be as little as five seconds. However, these have limited use, given that such embedded solutions only provide a limited functionality. What many users really need is their standard desktop operating system being available to use in the quickest time possible.

With just a few modifications and some experimentation, your Ubuntu box can realise its untapped potential. We have identified 8 tips to help you achieve this. Most of the tips are really easy to implement, and are perfectly safe. Nevertheless, it is always sage advice to backup data before experimenting with a machine. We would therefore recommend you backup your data before embarking on reading this article.

1. Remove the timeout

One of the easiest ways to make your Ubuntu machine boot faster is to simply remove the timeout in the boot loader. When your machine boots, a small countdown takes place. Historically, the purpose of this delay was to ensure that modules loaded in time for the kernel to boot. However, this is only really needed for legacy hardware. For modern computers, we can just remove the delay without any ill effect.

How to remove the timeout depends on what version of the GRand Unified Bootloader (GRUB) the computer is running. To check the version, type in a terminal:

grub --version

On our Ubuntu 9.04 systems, this outputs GRUB 0.97, which is best thought of as GRUB version 1. To remove the timeout, you just need to edit the file /boot/grub/menu.lst in a text editor (you need to use sudo for permission reasons). For example, to use gedit to edit the file you would type in a terminal:

sudo gedit /boot/grub/menu.lst

In this file, locate the line timeout=3 and change it to timeout=0. Save the file, and then reboot the system.

Please note that if your Ubuntu system uses Grub 2 (version 1.96), the procedure is different. With Grub 2 user-configurable settings are contained mainly in /etc/default/grub and the files in /etc/grub.d/. When update-grub is executed the results are input into the /boot/grub/grub.cfg file. To remove the timeout, you need to edit the file /etc/default/grub and change the GRUB_TIMEOUT line accordingly, and save the file. Then run update-grub which will update the /boot/grub/grub.cfg file.

2. Disable services that are not needed

A stock Ubuntu distribution cannot possibly meet the exact requirements of evey user. Consequently, there are some processes that are started up in the boot process that may not be required by some users. In these circumstances, resources are not being utilitised optimally, and the boot process is being extended unnecessarily. Moreover, as you try out new software and services you may find that boot times get longer and longer over time.

Bootchart is a handy utility which allows you to audit the boot sequence of your computer. It generates an attactive chart of the processes that are run at bootup, how long they take to initiate, and what resources they use. Armed with this information, you can identify the processes which take a significant amount of time to load, and then decide whether they can be removed.

Bootchart is not installed by default in Ubuntu, but this is easily rectified by installing it in the usual way with the Synaptic Package Manager.

The auditing is performed early in your boot sequence, and records system statistics as your computer boots.

When the boot loader starts, select the relevant kernel you are booting, press ‘e’ to edit the commands,and add the following to the kernel line:

init=/sbin/bootchartd

After booting, the software will have created a .png graphic chart in /var/log/bootchart/

BootchartThe screenshot on the left is the result from one of our test servers. Whilst the machine has a dual core processor it is slow to boot largely because we use it to test lots of software, which has in turn has installed numerous services. However, much of this software is not actually needed, and therefore unnecessarily extends the time it takes for the machine to be ready to use. Your bootchart might also look as bad as that machine.

Click on the image to make it full size

As you can see, there’s a whole raft of services being launched on this machine, many of which are not actually needed.

OK, bootchart lets you identify the services, but does not let you configure the services.

Ubuntu does not automatically install a graphical tool to disable services. The Boot-Up-Manager (BUM) is the most comprehensive and user-friendly tool for Ubuntu available, and can again be installed using Synaptic.

Boot-Up Manager is a graphical tool to allow easy configuration of init services in user and system runlevels.

Boot-UpManagerBefore removing a service, you should do some research to ensure that it is not essential to the operation of your machine.

Fortunately, Boot-Up Manager provides a detailed description of each service you have running, which should provide sufficient information to decide whether to deactivate the service.

On our test machine there are more than a dozen services we did not need, which shaved five seconds from the boot sequence.

I would stress that you should make a backup of your system before deactivating services.

3. Optimise memory

Another easy way to give a performance boost to your system is to modify how swap space is used, or more precisely how the kernel favors swap over RAM.

vm.swappiness is a kernel parameter that controls how much the kernel favors swap over RAM. In other words, it is a parameter which sets the kernel’s balance between reclaiming pages from the page cache and swapping out process memory. It is also defined as the tendency to steal mapped memory.

This variable kernel setting takes a value between 0 and 100. At 100, the kernel always prefers to find inactive pages and swap them out. With a value of 0, the system behaves so that applications that need memory can shrink the cache to a tiny fraction of RAM. Under Ubuntu the default setting for vm.swappiness is 60. To check this for yourself, type the command below into a console:

sysctl vm.swappiness

To modify this setting, simply open /etc/sysctl.conf with an editor and add the following line to the bottom of the file. You need root permissions to do this.

vm.swappiness=20

The lower the value of vm.swappiness the less the system will use swap space and the more data is cached to memory. We found 20 to be a good value for systems which have plenty of RAM (at least 1GB). If you don’t have enough RAM, setting vm.swappiness too low will have an adverse impact on system performance.

4. Improve hard disk performance

If your system has a DMA-compatible (Direct Memory Access) hard disk you can improve performance with a couple of tweaks. Not only will these help the system boot more quickly but the tweaks also have the added benefit of improving the general speed of your system too.

You may know that the hdparm tool can be used to speed test your disk and change a few settings. It can also be used to optimise drive performance, and turn on some features that may not be enabled by default. However, we would advise to back up important data before experimenting with hdparm, as it can crash a computer and destroy data if a few parameters are misused.

To measure your hard disk data transfer speed and tweak the settings you need to install the hdparm utility using the Synaptic Package manager. Once installed, enter the following command:

sudo hdparm -tT /dev/hda

For a SATA hard disk you would type:

sudo hdparm -tT /dev/sda

These commands show the data transfer speed. Best to run them a few times to get an accurate idea of the speed.

Here is some typical output:

/dev/hda:
Timing cached reads: 1932 MB in 2.00 seconds = 966.63 MB/sec
Timing buffered disk reads: 118 MB in 3.02 seconds = 39.06 MB/sec

To improve performance by turning on DMA, start up a terminal and type:

sudo hdparm -d1 /dev/hda1

(replace hda1 with the location of the boot partition; look at the output of the command df if you are unsure)

This command will need to be entered each time the system is started up, or you can modify your system so that this command is entered every time the machine boots up.

Currently all SATA hard drives automatically have DMA turned on, so there is no need to enable the -d1 flag. However, performance can still be improved by enabling read-ahead and write-caching.

Another way of improving hard disk performace is to turn off Automatic Acoustic Management (AAM). AAM is a method for reducing acoustic emanations. Since acoustic emanations are a byproduct of rotational speed, AAM provides a way to quiet a drive by limiting its rotational speed and power consumption—in effect, sacrificing performance for quieter operation. But if you are not concerned about noise, turning AAM off will slightly improve hard disk performance.

sudo hdparm -M254 /dev/hda1

(replace hda1 with the relevant partition on your system)

5. Run boot processes in parallel

Concurrent booting allows Ubuntu to take advantage of dual-core processors, as well as processors that hyperthread or multithread.

You can take advantage of running boot processes in parallel by editing the file /etc/init.d/rc in a text editor (with root permissions e.g. sudo gedit /etc/init.d/rc) and locating the following line:

CONCURRENCY=none

Change the line to:

CONCURRENCY=shell

Please note that this tip should not be used for systems with single core processors. Whilst it won’t affect the machine booting, you might find it actually degrades bootup time.

6. Reprofiling boot sequence

Ubuntu developers have done a good job in ensuring that the latest distro releases boot up at a good rate. Nevertheless there is more that you can do to quicken the process. For this tip, we will explore profiling.

One reason why systems can be slow to boot is due to excessive disk seeking. Fortunately, Linux has a mechanism called “readahead” which minimises this behavior. Profiling makes a list of all the files that are read during bootup. It then sorts the files according to how they are stored on the hard disk, saving the information into the /etc/readahead folder. Whilst Ubuntu ships with a readahead list, this is designed for the developers’ own system, and is not tailored to your computer and therefore does not reflect the additional services you might want to load during bootup.

Once profiling has been completed, Ubuntu reads your personalised /etc/readahead folder the next time the system is rebooted. Consequently, files are read faster for all future restarts of the system.

To profile the system, perform the following actions:

– At the bootup menu (GRUB), select the kernel you wish to profile (You may need to hit ESC to see the boot menu)

– Press e to edit the entry

– Select the line starting with kernel (or linux). Press e again

– Add the word profile to the end of the line

– Press b to boot (or Ctrl-X)

– Let the system boot to the login screen, and wait for all disk activity to stop. The system will boot slower whilst the profiling takes place. This is normal

– Restart the system

The speed increase to the boot time is dependent on the machine and how the files were already arranged on the hard disk. Neverthless, in many cases users should see an appreciable improvement in startup times.

Whilst this is a safe procedure, we would again recommend that you make a backup of any important data on your machine before proceeding.

7. Use a lightweight window manager instead of GNOME (or KDE)

Smaller footprint window managers and desktop environments drastically reduce graphical boot time, compared to the standard Ubuntu desktop environment (GNOME).

One of our favorite lightweight desktop environments is Xfce. Xfce is a free software desktop environment which aims to be fast and lightweight, yet at the same time being attractive and easy to use. Its configuration is entirely mouse-driven and the configuration files are hidden from the desktop user. It is based on the GTK+ 2.x toolkit (like GNOME).

XFCE

Xfce is lightweight and fast, and is not bloated by little-used features and options. This helps to reduce the time to takes to get to a usable desktop. Of course, Xfce does not only offer the advantage of faster bootup time. The enviroment has support for GNOME panel applets, has a very intuitive interface, comes with a minimal set of applications (but sufficient for most purposes – the file manager is particulary good), looks attractive, and importantly is frugal on RAM.

So, with Xfce you end up with a system that is not only quicker to boot, but also quicker to perform your daily tasks. A win win scenario.

8. Recompile kernel

The final tip is certainly not for the faint of heart. If you have a long weekend available and really want to get to the heart of your Ubuntu box, why not build a kernel which is tailored specifically to meet your requirements?

By only enabling the modules and drivers you need, the boot time of your system will be reduced. The added benefit is that this will also optimise the kernel to the user’s actual requirements. However, we recognise that for many Linux users this tip will be one step too far. Nevertheless, compiling the kernel is a good learning experience if you want to get under the bonnet of Linux.

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Please read our FAQ before making a comment.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments