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.

  1. use bootchart to profile boot times and bootlenecks easily through an intuitive image graph
    install with

    sudo 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)

  2. 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.
  3. 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!
  4. disable sl-modem-daemon startup service (uninstall that package) if you do not need to use the analog 56kbps modem.
  5. vmware-networking in vmware workstation 6.5 and 6.5.1 lags at boot time, consider switching to VirtualBox virtual machine.
  6. 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.
  7. 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.
  8. 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).
  9. 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
  10. (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
  11. 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
  12. 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/sda9

    change the UUID code in both these files
    /etc/fstab
    (only change the one concerning /dev/sda9!)
    /etc/initramfs-tools/conf.d/resume

    rebuild the initramfs with
    update-initramfs -u

    You 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!)

  13. 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

  1. 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.

  2. (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 | 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
    done

OPTIMIZATIONS NOT RELATED TO STARTUP

  1. 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
  2. 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.
  3. 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 ttf

    your 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.

  4. Enable Ethernet network offloading
    click here for the howto
  5. 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)
  6. 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
  7. 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

Related posts:

  1. Swap Area not working
  2. Managing startup services
  3. Linux Power Saving Tweaks for HP Pavilion laptops
  4. [EN] Configure HP Pavilion QuickPlay multimedia buttons in Ubuntu Linux
  5. working with system logs
  6. Disk quota management
  7. HowTo: Ubuntu Linux on HP Pavilion series laptops
| Print This Post Print This Post | Email This Post Email This Post
RSS 2.0 | Trackback | Comment

32 Responses to “Speed up Ubuntu Linux!”

  1. ,[...] aldeby.org is one another must read source of information on this issue,[...]

  2. [...] here’s a very comprehensive list of what can be done now in Ubuntu Karmic to get that moving along more briskly. I haven’t [...]

  3. [...] but this info may help enough to figure it out yourself, or to google more accurately. Also, http://linux.aldeby.org/speed-up-you…inux-boot.html in general is a good reference for speeding up Ubuntu (most of these tips *should* work with Arch) [...]

  4. Paul Reiber says:

    I’m surprised you didn’t mention tweaking the atime setting on various mounted partitions.

    http://we-are-all-robots.blogspot.com/2009/06/atime-relatime-and-noatime.html and others; google for ‘noatime relatime atime’ and enjoy the read.

    End-users running programs requiring atime updates (mutt?) might still benefit from this; they can set the partition where mutt’s files live to use nodiratime rather than noatime, and use noatime on all OTHER partitions just fine. Google ‘nodiratime’ for more info.

    Regards,
    -pbr

    • aldeby says:

      Thank you Paul for highlighting this point!
      I’ve just added it to the post. I was using relatime only while on battery with laptop-mode-tools, however there is actually no reason why not using it also on a daily basis!

      Your feedback is precious, also the one concerning the mistyped referrer.
      This blog couldn’t be this popular without contributions from users like you! Thank you!

      • Paul Reiber says:

        Happy to help!

        This article was a WIN for me from the very first recommendation – I wasn’t aware of bootchart, and it ROCKS.

        Thanks for making me (and others) aware of it, and providing various clues on other optimization tools/techniques as well.

        I’ll leave you with one final (but controversial) recommendation for optimizing a Linux desktop:

        *Switch to using Google Chrome instead of FireFox.* If you need FF for some specific feature or website, sure, use it… but Chrome runs SO much faster than FF, it’s disturbing to go back once you’ve gotten used to it.

  5. Paul Reiber says:

    Link is broken in item 3; I believe you want it to refer to: http://linux.aldeby.org/?s=managing+startup+services

Leave a Reply

XHTML: You can use these tags: b, cite, code, em, i, q cite="", strike, strong.