Results 1 to 10 of 180

Thread: TIP: Improve bootup speed by reprofiling bootup

Threaded View

  1. #1
    Join Date
    Oct 2004
    Cupertino, CA
    Ubuntu 10.04 Lucid Lynx

    TIP: Improve bootup speed by reprofiling bootup

    Digg this story

    This tip applies to Ubuntu Dapper 6.06 or newer. It won't do anything if you try it on an earlier version. I typically don't like bootup gimmicks and other silly tweaks that really don't do much, but I seriously do believe you can benefit from this one... I've made an effort to explain how it works in addition to just doing it, so if you're impatient, start scrolling down.

    Disclaimer: This is a safe procedure that utilizes well-tested and noninvasive code already contained in Ubuntu's bootup procedures, but are not activated by default. However, I can't be responsible for any misfortune it may inflict in your computer.

    One cause of slow bootup is excessive disk seeking -- as files are being read off the disk in arbitrary order, the disk heads have to jump all around looking for the files. If during your bootup, you hear the disk making a constant grinding noise loading files, you could possibly help your bootup speeds through this tip. On the other hand, if the hard disk does not appear to be working that hard, and your slow bootup is caused by intermittent "pauses" in bootup, then this tip may not be as handy for you, and you should investigate into other reasons why your bootup is slow (i.e. trying to get an IP on a slow network, etc).

    What does this procedure do?
    Ubuntu has a mechanism called "readahead" that attempts to minimize disk seeking. During a profiled bootup, Ubuntu will make a list of all the files read from the disk during the bootup procedure. It then sorts the files by the order in which they appear on your hard disk, and saves it into the /etc/readahead folder. On subsequent bootups, Ubuntu will first read this list of files into RAM. Since this list of files are in order, it should be faster to read them all at once rather than on an as-needed basis at bootup. In addition, this gives your hard disk something to do during the loading drivers and getting IP address phases of bootup, where usually the hard drive would be idle. As a result, bootup will be faster.

    Isn't readahead something already set up in Ubuntu? Why am I running it again?
    Well, Ubuntu ships with a default readahead list. Basically, the developers ran this procedure on their computer, then you use their list. However, this list may not reflect how files are laid out on your hard drive. Also, it may not reflect what you load during bootup, especially if you've installed any extra services. In addition, if you're running a development build of Ubuntu, this list might not be accurate at all.

    Does it actually help?

    Well, on my system, it took around 10 seconds off the bootup. I can't say what it'll do to you, but it doesn't hurt to try!

    However, if you have an insanely fast computer, it could be that readahead won't help your bootup times, as your system can handle bootup seeking without delay (and perhaps also your system doesn't wait long for the network to come up or hardware to be detected). So, your mileage may vary.

    Why isn't this done periodically by my computer, if it helps so much?

    Well, the process of refreshing the readahead list introduces overhead, and makes your system boot slower that one time. It's not really fair for the computer to arbitrarily decided that THIS bootup should be 25 seconds slower

    How do I do it?

    (1) At the bootup menu (GRUB), select your default kernel. You may need to press ESC to see this menu.

    (2) Press e for edit.

    (3) Choose the first line (it should start with "kernel"). Press e again.

    (4) Move to the end of the line, then add the word profile. Press enter.

    (5) Press b to boot.

    (6) Let the system boot to the login screen, and wait for all disk activity to stop. Remember, during this one bootup, you've told Ubuntu to keep track of all disk activity going on, in order to build that list. Don't be surprised if it's significantly slower than your ordinary bootups -- that's why it's not activated by default, remember?

    (7) Reboot your system, and enjoy the results.

    How often should I repeat this procedure?

    I recommend doing it:

    * Once after you install Ubuntu and get the system set up the way you like.
    * After doing a major upgrade, such as to the next version of Ubuntu. No need to do it for regular updates, etc.
    * After setting up prelink (if you use it), since that could cause bootup files to change locations on your hard drive
    * After restoring your entire system from backups, as that would change locations of files on your hard drive.



    Here's another related tweak that could help. It is a little more involved, but for me, the results shaved another 10 seconds off my bootup.

    How does this one work?
    By default, readahead is done in the background, while the rest of the system is booting up. I suspected that this could lead to more disk seekage, so I tried making readahead finish first, before allowing the rest of the bootup continue. To my delight, it took 10 seconds off my bootup.

    Why isn't this default?
    The three reasons I can think of are:

    (1) Users would falsely file bug reports or complain that "Reading Desktop Files" is taking a long time to run on bootup (~10 seconds on average), not realizing that in doing so it saves them LOADS of time through the rest of bootup.
    (2) The LiveCD would be agonizingly slow to load!
    (3) People with insufficient RAM to cache the readahead would not receive much benefit from this form of readahead, which can worsen bootup time.

    How do I do this?

    (1) Perform the above profiling procedure. It is important that the order is correct, else this form of readahead won't do a thing!
    (2) Use your favorite text editor (under sudo or root privileges) to open /etc/rcS.d/S01readahead
    (3) Find line 21, which reads:
                if /sbin/start-stop-daemon --start --quiet --background \
    Remove the --background, so that it reads:

                if /sbin/start-stop-daemon --start --quiet \
    (4) Save, reboot.

    It didn't help. How do I go back?
    Just reverse step 3, putting --background back in.

    Whoa! This really helped! Make it default for the next Ubuntu release!

    It actually is in Edgy and beyond. A reverse of the hack is to add --background again, which some people reports is slightly faster. This completely depends on your hardware/software setup and whether your boot is IO bound or wait/modprobe-bound.
    Last edited by jdong; November 29th, 2008 at 07:42 PM. Reason: Add obligatory digg link... hopefully doesn't bring the forums down :P
    Quote Originally Posted by tuxradar
    Linux's audio architecture is more like the layers of the Earth's crust than the network model, with lower levels occasionally erupting on to the surface, causing confusion and distress, and upper layers moving to displace the underlying technology that was originally hidden


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts