Speed up Ubuntu Linux!
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)
- Upgrade to Ubuntu Karmic 9.10. In this version of Ubuntu Linux most of the services have been transitioned from the venerable System-V init daemon to the new upstart daemon by Scott James Remnant, Ubuntu employee. This transition has highly improved the speed of both startup and shutdown processes.
- 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! - disable sl-modem-daemon startup service (uninstall that package) if you do not need to use the analog 56kbps modem.
- vmware-networking in vmware workstation 6.5 and 6.5.1 lags at boot time, consider switching to VirtualBox virtual machine.
- 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. 3 vts should be enough. The benefit from this is anyway extremely small.
- Profile your boot (NOTE: from Ubuntu Karmic 9.10 profile is automatically invoked at any major software update)
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. - 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). - in the file fstab also tweak your filesystems to support relatime instead of atime. This should be the default for kernels 2.6.30 upwards though (Ubuntu Karmic 9.10 runs 2.6.31 and includes this change). The rationale is that with the atime option enabled the kernel always has to perform a write operation to the disk when the kernel accesses a file, even without modifying its contents. With relatime this occurs only when content is modified reducing this way the number of write operations. Thank you to Paul for highlighting this.
UUID=1234567-abcd-efghi-ab12-1234567 / ext3 relatime,errors=remount-ro 0 1
- (NOTE: from Ubuntu Karmic 9.10 and the transition towards upstart this is enabled by default)
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 - Some people report increasing the programs loading times by using prelink program. This is intended to prelink binaries to libraries only once in a while instead of each time the executable is launched. The time saved varies according to each program and its use of external libraries.
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.
IMPROVE GNOME STARTUP/LOADING TIME
- In System -> Preferences -> Startup Applications disable the unneded services and edit every entry you still need to load deferring the loading time. The rationale is that all these services are not needed to load GNOME and thus can be loaded a few seconds after the desktop environment has loaded its core components.
In order to achieve this goal edit every command section as follows:sh -c "sleep 60; exec bluetooth-applet" or sh -c "sleep 30; exec /usr/lib/evolution/2.28/evolution-alarm-notify"
the number after sleep indicate the seconds after which the command is run.
Try to set a number greater than 30 and different numbers for each service prioritizing those you consider more important while further deferring the least important ones. - (NOTE: from Ubuntu Karmic 9.10 sreadahead is installed by default. This is an improved version of readahead)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 | lessThis 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 done
OPTIMIZATIONS NOT RELATED TO STARTUP
- Move your temporary files /tmp folder to your RAM if you have loads of memory. This will also provide you greater privacy. Edit /etc/fstab and add the following line to it
tmpfs /tmp tmpfs defaults,noexec,nosuid 0 0
- 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 since they will speed up font cache rebuilt.
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
- Disable all the not needed plugins in gedit, gnome default text editor. Gedit text editor is a pretty fast application, however some plugins do really put a burden on it! You can disable them from menu Edit -> Preferences -> Plugins
- Improve OpenOffice startup speed: from within one OpenOffice window select Tools -> Options -> Memory
Number Of Steps: 30
Use for OpenOffice.org: 128
Memory Per Object: 20
Number Of Objects: 20
Enable Quickstarter: Checked
Related posts:
- Swap Area not working
- [EN] Configure HP Pavilion QuickPlay multimedia buttons in Ubuntu Linux
- Linux Power Saving Tweaks for HP Pavilion laptops
- Managing startup services
- working with system logs
- Disk quota management
- Enable larger persistent data for Linux Live on SolidState or USB devices
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!