Speed up your Ubuntu Linux boot!
In the following tutorial you are going to fine tweak your Ubuntu Linux setup in order to speed up the boot process as well as the startup time of some frequently used applications.
use bootchart to profile boot times and bootlenecks easily through an intuitive image graph
install withsudo apt-get install bootchart
then you’ll get a graph in /var/log/bootchart directory each time you boot your system.
charts will be looking like the image on the right (click to zoom)
- either install
a) sysv-rc-conf
b) bum (advised)
utility to tweak services startup
Comments on what some services actually are meant to can be found here http://ubuntuforums.org/showthread.php?t=89491.
Be careful in disabling services since many despite not being necessary provide indeed useful features! - (11 seconds save!) disable sl-modem-daemon startup service. This service is indeed buggy!
- remove a few tty. By default there are F1 through F7, we do not need all seven: in folder /etc/event.d/ comment out all entries in tty4 tty5 files. Three vts should be enough.
- Profile your boot.
When you have the Grub menu to start your system, hit the “e” for edit the kernel line you normally start with. Then move to the end of the Kernel line and edit quiet splash to quiet splash profile. Don’t save this line just let it boot up “b” once with this profile parameter.
This boot will go very slow because it is profiling (read putting all read disk blocks behind each other) the normal boot to optimize performance. All subsequent boots will then go faster. If all boots go very slow afterwards make sure that the profile parameter was not saved as a boot option. - Configure readahead to preload files needed in your dektop environment while waiting for the username and password prompt. The more RAM you have the more you can preload. 512 is really the minimum.In /etc/readahead you can find the lists of preloaded files for the boot sequence (we have customized this in the previous step). Now we are going to create a profile of our desktop.
At the login prompt, now change vts with CTRL+ALT+F1, login and write down
sudo readahead-watch -o /etc/readahead/gnome /This will grind the disk for a while then it will return you to a command prompt. The profiler is now in the background watching all actions. Now, without logging out, go to your destop login prompt (ALT+F8 ) and log in normally. After you are fully logged in, press CTRL+ALT+F1 to go back to your terminal, and stop the profiler with
sudo killall readahead-watch
We would have to prune the resulting list a bit as Jdong suggests: In a terminal, run:cat /etc/readahead/gnome | xargs -i ls -lk {} | sort -rn -k +5 | less
This will display all the files readahead wants to cache, sorted by largest file first. The 5th column (before date) is the size of the file in KB. Make sure there’s nothing too large. If it’s bigger than 10,000KB or so, it’s probably not worth preloading. You can remove unwanted files from the preload list by opening /etc/readahead/gnome in your favorite editor, and deleting its line.
NOTE: If you have your home on a different partition, you should repeat the previous steps for each partition, replacing ‘gnome’ filename with a different name and the mountpoint / with each interested mountpoint.
To make your linux box apply this trick at every boot edit file /etc/rc.local and add in the line preceding ‘exit 0′:
for list in /etc/readahead/*; do
readahead-list $list
donecredits and reference: http://ubuntuforums.org/showthread.php?t=565651
- (2 seconds save!) check the sixth column in file /etc/fstab set 0 for devices that do not need to be checked regularly
set 1 only for root /
set 2 for other partitionsThis is the standard, however you could have wrongly edited fstab file. This setup ensures only root filesystem is quickly checked at boot time, thus saving a little time excluding other filesystems when not necessary (these will be checked only after a dirty shutdown or on a scheduled basis).
- (6 seconds save!) Enable concurrent booting allows Ubuntu to take full advantage of dual-core processors, as well as processors that hyperthread or multithread.NOTE: this doesn’t seem to work for me. It messes up GNOME loading, probably due to an unsolved race condition. However, if you manage to have it notably improves your boot loading time.These settings are located in your /etc/init.d/rc file.
sudo gedit /etc/init.d/rc
Look for CONCURRENCY=none and change it to:
CONCURRENCY=shellrace conditions problems with dbus hal and gdm exhist
http://ubuntuforums.org/showthread.php?t=574992
https://bugs.launchpad.net/ubuntu/+source/hal/+bug/149881 - I have read a lot about using prelink program. This is intended to prelink binaries to libraries only once in a while instead of each time the executable is launched. This should save some time. However I have also read that prelink is no longer needed in recent Ubuntu versions, even if I could not figure out why.By the way it didn’t either slow down my system if ever it has speed it up.
You can install prelink via
sudo apt-get install prelinkthen run it the first time with
prelink -mR
reference here http://ubuntuforums.org/showthread.php?t=1971
http://ubuntuforums.org/showthread.php?t=74197
- Enable Firefox pipelining
type about:config in Firefox’s address bar.
Type pipelining in the filter text box. This will leave three options on screen.
Double-click network.http.pipelining to turn its value from false to true.
Do the same for network.http.proxy.pipelining
Double-click on network.http.pipelining.maxrequests and change “4” to “6.” (do not increase this value beyond)
Finally, on any blank space in the browser window, right-click and choose New>Integer
When prompted for a name, type nglayout.initialpaint.delay and set its value to 0. - Figure out SWAP problems.
Indeed swap has a high impact over our system performance, however I am not going to focus on swap usage here, but on swap misconfiguration. This can lead to a 10 seconds delay in the startup / boot process.Symptoms: Splash screen freezes after about 10 seconds of normal boot and stays this way for about a minute or so and never resumes (all text mode boot after). The boot process is stuck for 10 seconds after launching local-premount scripts with following message:
Begin: Waiting for resume deviceThis behavior is caused by the fact that you have somehow modified your swap partition (new linux setup? new hard disk? swap partition resize?) and thus initramfs-tools cannot find the partition through the old UUID.
first make the swap partition work again by
sudo mkswap /dev/sda9
(where sda9 should be the corresponding partition on your system. Check gparted to ensure this. This will DESTROY all your data if you use it on a data partition, like your /home one)then compute the UUID of the new swap partition
sudo blkid /dev/sda9change the UUID code in both these files
/etc/fstab
(only change the one concerning /dev/sda9!)
/etc/initramfs-tools/conf.d/resumerebuild the initramfs with
update-initramfs -uYou can also change back the swap UUID with this command
mkswap -U UUID /dev/swapdev
where UUID is the ID shown in both mentioned /etc files (the ID should be the same in both them, otherwise follow the 1-3 steps!) - Here follow other useful speed optimizations not actually related to the boot process
- Remove unnecessary font packages:
in a terminal issue the command:dpkg -l | grep ii| awk '{print $2}' | grep ttfyour output would be probably far too long. You may safely remove all packages except for the following ones: ttf-bitstream-vera, ttf-dejavu, ttf-dejavu-core, ttf-dejavu-extra, ttf-freefont, ttf-opensymbol AND those of the languages you actually use on your system (check each package language searching for it with Synaptic package manager).
All the other ones can be safely removed. - Consider removing mono framework.
sudo apt-get --purge remove libmono0NOTE: this would remove also some default applications such as Tomboy (replace it with ZIM or Basket Note Pads), and F-Spot (replace it with gThumb)
Print This Post
|
Email This Post


This is cool version of the cat sort command
cat /etc/readahead/gnome | xargs -i ls -lk {} | sed -r -e ’s![-rw0-9]* [0-9] [a-Z]* [a-Z]* !!’ | sed ’s!\([0-9]*\)!\1 : size !p’ | sort -rn -k
I don’t remember how I figured it out, but that long 10s delay in my bootchart was due to usb issues.
I disabled USB Legacy Support in my bios, and that 10s was shaved down to 2s, score!
Hey Aldeby,
It seems I am not allowed to upload image files on the contact page (png’s at least). Should I send it to you another way?
Hi Zapps!
The attached bootchart does not represent my machine.
In my case I only have an initial delay of <4 seconds during which the computer initializes all the main ports and pheriferals. Please notice that the bootchart here attached is missing a section at the bottom which actually shows the devices initialization. I have some partitions on my harddisk, however they are usually mounted later. At first only root / is mounted.
If you wish you can send me your graph via the contact form on the contact page.
I’ll be glad to comment it to you.
I see your boot chart has a 10s delay after init that no processes are working, just like I do. Have you happened to figured out why this happens and what can be done? Shaving 7 of those 10s off would be very nice! Was this bootchart generated on a laptop, with several partitions?
Thank you very much for the great information-
Yes i think it’s the packet bootchart instead of bootchard
sudo apt-get install bootchart
I saw your blog is under licence Creative Commons, but i prefer ask you before : can i translate some part
of your article for my blog and maybe of course for the french ubuntu documentation, please?
Thx
wolfie2x,
you can check if you have saved it editing menu.lst file.
gksu gedit /boot/grub/menu.lst
there check the last 20 lines and see if you have ‘profile’ at the end (or elsewhere) in the kernel boot line (maybe after ’splash’ and ’silent’).
I don’t think e2fsck -fD is related to the programs crash… by the way there is no way to undo it.
-D option optimizes directories in filesystem. This option causes e2fsck
to try to optimize all directories, either by reindexing them if
the filesystem supports directory indexing, or by sorting and
compressing directories for smaller directories, or for filesys‐
tems using traditional linear directories.
Even without the -D option, e2fsck may sometimes optimize a few
directories — for example, if directory indexing is enabled
and a directory is not indexed and would benefit from being
indexed, or if the index structures are corrupted and need to be
rebuilt. The -D option forces all directories in the filesystem
to be optimized. This can sometimes make them a little smaller
and slightly faster to search, but in practice, you should
rarely need to use this option.
The -D option will detect directory entries with duplicate names
in a single directory, which e2fsck normally does not enforce
for performance reasons.
I tried “5. profile your boot”, and every boot seems to be slow. what do u mean “Don’t save this line just let it boot up..”? how do I know if it has been saved? how can it be undone?
also I tried another optimization mentioned elsewhere:
e2fsck -fD /dev/sda7 (from Ubuntu live CD; with file system unmounted), and now some programs are crashing with segment fault. Anything to undo/fix it?
Whoops! You are right bdk, the actual path is /var/log/bootchart. I just corrected it. Thanks for making me notice the mistake.