Rabu, 01 September 2010

Optimize startup for faster boot times

Few operating systems seem to boot quickly enough, and unfortunately
Ubuntu is amongst them. However, there are four things you can do to
reduce delays and generally speed-up startup:
• Reduce or eliminate the boot menu countdown;
• Make boot runtime scripts start in parallel;
• Build a read-ahead profile personalized to your PC;
• Reduce the number of GNOME startup programs.
Reducing the boot menu delay
If you dual-boot Ubuntu and Windows on your computer the boot menu
appears for 10 seconds, during which you can select either Windows or
Ubuntu. If you only have Ubuntu installed, a prompt appears for three
seconds telling you that you can hit a key to see the boot menu.
This delay can feasibly be reduced to one second, providing you have
quick enough reactions—hitting a key during that second will cause
the countdown timer to stop so you can make your choice at leisure.
Alternatively, you can configure the system so the boot menu never
appears. This will deny access to the other boot menu options but if
Ubuntu is the only operating system on your computer then this could
be a good arrangement.
Start by opening the boot menu configuration file in Gedit:
$ gksu gedit /boot/grub/menu.lstThen search for the line that reads timeout 10 and change the 10 to read
either 1, for a one second countdown, or 0, to disable the boot menu
completely. See Figure 3.1, on the following page for an example from
my test PC.
Save the file and then reboot to test the settings.
Run boot-time scripts in parallel
Whenever Ubuntu boots it runs several scripts that start necessary
background services. By default these are set to run one-by-one but if
you have a processor with more than one core, such as Intel’s CoreDuo
series or AMD’s Athlon X2, you can configure Ubuntu to run the scripts
in parallel. This way all the cores are utilized and quite a bit of time can
be saved at each boot.
To make the change, type the following to open the necessary configu-
ration file in Gedit:

$ gksu gedit /etc/init.d/rc

Look for the line that reads CONCURRENCY=none and change it so it
reads CONCURRENCY=shell. Then save the file and reboot your computer.
Using this method I managed to shave a massive 20 seconds off my
desktop PC’s usual start-up time of just under a minute.
Build a readahead profile personalized to your computer
Ubuntu includes a software called readahead that, according to the
official blurb, “allows the user to specify a set of files to be read into the
page cache to accelerate first time loading of programs”. In other words,
it allows Ubuntu to cache frequently accessed files to avoid searching
around for them at startup. A default readahead profile is included with
Ubuntu but you can create your own, tailored to your system.
Reboot Ubuntu and, at the boot menu, ensure the usual Ubuntu entry
is highlighted. Then hit e . This will let you temporarily edit the boot menu entry. Use the cursor keys to move the highlight down to the
second line that beings kernel and hit e again. Use the right arrow key
to move to the end of the line and, after the words quiet and splash, add
the word profile. See Figure 3.2 for an example taken from my test PC.
Then hit Enter and then b to boot your computer. Note that the first
boot will be slow because the readahead cache will have to be rebuilt.
In subsequent boots, however, you should see speed improvements.
I experienced a couple of seconds improvement by building a new reada-
head profile. This isn’t a dramatic increase but it was certainly worth
doing.
Trimming the GNOME startup programs
Once you’ve logged into the GNOME desktop, you’ll face yet another
delay as all the GNOME background software starts. A few seconds
can be saved by trimming this list and that can be done using the
GNOME Sessions program (System → Preferences → Sessions). Ensure
the Startup Programs tab is selected and then look through the list for
items you might want to prune. For example, if you’re never going to
use Evolution’s alarm function then Evolution Alarm Notifier can be dis-
abled by removing the check alongside it. One word of warning: Volume
Manager isn’t related to audio. Instead it enables the automatic detec-
tion of external storage devices that are attached to your computer.
As such it should always be enabled. Nor should you disable Network
Manager—this is necessary to get Ubuntu online if you’re using wifi. (If
you absolutely have to disable it, follow the instructions in Tip 43, on
page 103, which explains how to configure Ubuntu’s network compo-
nent using the older Network Settings tool.)

0 Comment:

Posting Komentar