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)
- utility to tweak services startup
refer to post Managing startup services
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! Recent version provided with Ubuntu Intrepid has this issue fixed.
- (7 seconds save!) vmware-networking in vmware workstation 6.5 and 6.5.1 lags at boot time.
- 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.
You can install prelink via
sudo apt-get install prelink
then run it the first time with
prelink -mR
and edit file /etc/defaults/prelink and change “PRELINKING=unknown from “unknown” to “yes”reference with performance benchmarks here
http://www.quintinriis.com
http://ubuntuforums.org/showthread.php?t=1971
http://ubuntuforums.org/showthread.php?t=74197
- 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!) - Disabling in BIOS USB Legacy Support lets you gain ~8 sec. that the system usually spends probing USB 1.1 legacy devices.
OPTIMIZATIONS NOT RELATED TO STARTUP
- 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. - 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. - Enable Ethernet network offloading
click here for the howto
- Consider removing mono framework.
sudo apt-get –purge remove libmono0
NOTE: 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) - Preload is an “adaptive readahead daemon” that runs in the background of your system, and observes what programs you use most often, caching them in order to speed up application load time. By using Preload, you can put unused RAM to good work, and improve the overall performance of your desktop system.
This does not waste much RAM, and does not either improve boot up speed, it only acts for applications started after the boot up process.
use sudo apt-get install preload to install it,
use sudo apt-get install ld.so.preload-manager to install a program useful to manage the preloaded ones.reference: http://www.techthrob.com/tech/preload.php
Print This Post
|
Email This Post


Isn’t the package ‘bootchart’ and the files are created in /var/log/bootchart? I hadn’t heard about it till I stumbled here and installed it. Pretty awesome app, though my first reboot was pretty long due to the scheduled fsck.
Whoops! You are right bdk, the actual path is /var/log/bootchart. I just corrected it. Thanks for making me notice the mistake.
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?
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.
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
Thank you very much for the great information-
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?
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.
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?
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!
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
[...] Speed up your Ubuntu Linux boot! | Nobody was Born with Linux Knowledge. [...]
how does removing libmono make ubuntu boot faster?
Most of these comments tell me what to do but not how to do it… not a good thing to do for newbies. Also, your comments on booting do not apply to those of us who use the Windows bootloader (i.e., we installed using WUBI).
@MossBliss - if it doesn’t apply, then don’t try it - no problem.
Trying this kind of thing - any kind of sudo editing - can completely trash your system. Just one character in the wrong case in one file saved is enough - and if you don’t write down every step (it’s a good idea to keep an A4 pad and a pencil to write the time, and a quick note at each step) then you’ll find the only way out is to reinstall.
Also, if you’re messing like this, it’s clever to have /home on a separate partition.
Tweaking like this maybe fun - but it’s not worth it for most people. I tried ‘concurrency+shell’ and learned a hard lesson - reinstalled and didn’t lose much more than a day’s messing and updating.
Concurrency needs startup scripts sequence to be fine-tuned in order to prevent race conditions.
At the moment is advised against enabling it.
However, in case you have enabled it and the system fails to prompt you with the graphical login and desktop you can easily revert the changes by editing back
/etc/init.d/rc
using the safe mode boot option -> root terminal -> pico /etc/init.d/rc
if things get messed up badly you can revert the changes by editing the file from an Ubuntu live CD and chrooting to the local setup.
Of course your advice to keep track of every change until you can achieve system stability is wise, however none of these changes puts your data and filesystem in danger and all can be reverted easily.
Thanks for the feedback!
Any chance of an update on this thread? taken from the starting place of 9.04! I know they have done a lot of work solving some of the problems from before but I think that you could help us top that no?
Oh yeah, I think Jaunty is already quite fast at booting but maybe there are still some finetunes… can you tell us which are them?