Slashdot Mirror


How To Speed Up Linux Booting

An anonymous reader writes "A common complaint about Linux is the amount of time the operating system takes to start. Like Linux itself, there are plenty of options and lots of flexibility for boot-time optimization. From dependency-based solutions like initng to event-based solutions like upstart, there's an optimization solution that should fit your needs. Using the bootchart package, you can dig in further to understand where your system is spending its boot time to optimize even more."

22 of 301 comments (clear)

  1. Boot time not an issue. by AmIAnAi · · Score: 4, Interesting

    I thought one of the arguments for linux was that you didn't need to reboot - like you do with Windows. So the boot time should not matter :-)

    --
    Any sufficiently advanced bug is indistinguishable from a feature.
    1. Re:Boot time not an issue. by arth1 · · Score: 5, Interesting

      Indeed. The boot time of a system you boot once a year is rather irrelevant.
      Laptop, you say? Hibernate, don't boot!

      What's more interesting is to reduce the login time and start-up time for applications. prelink is your best friend here. Make sure that all your apps are compiled for position independent code (PIC), and prelink them. Lots of time saved, at the expense of larger binaries.

      Regards,
      --
      *Art

    2. Re:Boot time not an issue. by Micah · · Score: 4, Interesting

      In my Kubuntu Feisty install, Hibernate takes about as long as shutting down and starting it back up about as long as a normal start.

      Of course, all the apps are still there so that helps. But it's not nearly as efficient as, say, a Mac where you can close the lid any time, open it back up again and have it right there in 2 seconds.

    3. Re:Boot time not an issue. by Bert64 · · Score: 4, Interesting

      But as you said, for the first few minutes after boot, windows is thrashing the disk and running slower... Sometimes it even does ridiculous things, like closing the start menu while your trying to select something from it, or ignoring some mouse clicks.
      You could make linux start in the same way, modify the init scripts to start XDM first, and everything else later, in which case you'd have the same appearance of fast booting.

      --
      http://spamdecoy.net - free throwaway anonymous email - avoid spam!
    4. Re:Boot time not an issue. by cmacb · · Score: 3, Interesting

      To be fair, my Windows box boots pretty quick; I think the time between power on and desktop is somewhere in the region of 50 seconds.


      The only reason you can say that 50 seconds seems pretty quick is that most of us remember when several minutes was he norm. The interesting thing is that as feature creep in all operating systems has continued (you can't have glass windows in one OS without users of all other OSs feel the "need" for it too after all) has kept boot time longer than we would like, even though hardware speeds have continued to increase by orders of magnitude.

      Can you imagine how long an XP boot (or Ubuntu for that mater) would take on an old 386 system with a sluggish hard drive and not a lot of memory (if such a thing were even possible)? Hours I would guess, and you would shake your head wondering if your hard drives MTBF would get you through the process.

      In the future will it take four or eight processors in a box to keep the lag down to 50 seconds? Should we take any delight in the fact that Windows boot will be sped up again only by special code to pre-load parts of the OS into flash ram before shutdown? I don't. I'd much prefer to see an almost-instant-on OS that didn't depend on special hardware tricks but rather because the architects actually designed the bloody thing for a change. Aint gonna happen though. If there are still any really smart people working at MS I'm sure they are working on the next great Google/Sony/IBM/Oracle killer or something. Faster boots would benefit ALL Windows users, not just MS only shops. We can't have that now can we?

      It's a good sign when an OS rarely needs to be booted, which is at least the case with Linux and OS X (can't speak for Vista). I leave my machines running all the time, even my desktop has laptop innards, so they go into a low power state when not used for a while. What I do to clean up any cruft that has built p running poorly behaved applications is to reboot when I am done using the computer for a while. That way I don't have to sit around and wait for the process to complete. the machine reboots, sits there for thirty minutes and then goes to sleep. It's ready to go and "freshly" booted the next time I need it. Of course if you like to keep a lot of memory hogs autoloaded and running in the background this system may not work so well.
    5. Re:Boot time not an issue. by TheNetAvenger · · Score: 3, Interesting

      guess the point is that we *should* be switching our machines off whenever possible as opposed to leaving them running for no reason. The home user isn't going to be persuaded by Linux if he/she has to wait a long time to actually get a computer into a usable state*.


      Yes, but rebooting should not be the option people are using. Go the power management route and do things like enter low power mode, or do a full suspend to disk (hibernate).

      Rebooting really should not the solution to using less power, especially with the Power management concepts can be automated based on idle usage, turn themselves back on to run tasks and back off.

      I got into this habit from carrying a couple of laptops full time, and it is something I carry over to my personal desktops as well.

      People need to just exchange Off with Hibernate in their minds. Even with Windows, which doesn't have bad boot times, it is just easier to tell the system your power button is the hibernate button, and hit it and go on my way. Then turning on the computer is a few seconds and I don't have to worry about what I left running ever. Especially with someone like me that has tons of crap running all the time, including several VMs which I don't have to individually suspend to disk if I were to shut down the computer everytime.

      And thank god OSX finally added a true hibernate in 10.4 on their notebooks, cause not having it about drove me flipping insane.

      So now that 99% of all OSes have ok power management, rebooting should be a thing of core updates only.

      PS
      The boot times on Linux are really not bad in a default install on most distributions. And people shouldn't take this article as evidence that Linux is slow or sucks at boot times.

      However, I do applaud the efforts to improve boot times, and wish there was a bit more generic optimization like people from the Windows world are use to.

      Vista for example monitors the last 5 boot times, and will continually adjust disk layout and process order, etc to continue to speed up boot times. There is no reason all OSes couldn't add a generic form of optimization like this.

    6. Re:Boot time not an issue. by EsbenMoseHansen · · Score: 2, Interesting

      hibernate has to restore the entire state of RAM. It doesn't matter if you had 200MB or a 3 GB of applications, it's all gotta come back in before you start running the kernel.

      Actually, it is only the application areas that has to come in... disk cache on so on doesn't. I sometimes wonder if there should be a "shutdown" signal in the XSMP setup that would enable applications to dump cached data that would probably be stale anyhow when the computer is brought back on line, such the browsing cache.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
  2. Customize the Bootscript, Trim the Fat by Old+Duck · · Score: 5, Interesting

    Most bootscripts are very generic in that they will try to load all sorts of RAID drivers, various services that are not needed, special fonts, etc.. I've gone in on my computers and wrote a very simple, quick, and to-the-point bootscript (easy to do with a little BASH knowledge), and my system boots up remarkedly fast. Granted, my bootscript isn't very portable, but one of the benefits of Linux is the ability to customize it.

    Another trick is to prelink files and let KDE (if that is what you use) know about it. Even the startkde script can be long and drawn out, so trimming the fat and only including what's needed on your system can make a big difference. I've shaved over 13 seconds off a boot sequence by writing a minimum bootscript for my hardware, and that was using a relatively fast distro to start with.

    -Mike

    --
    There are more things in heaven and earth, Horatio, Than are dreamt of in your philosophy.
  3. The "bootchart" tool looks promising. by Animats · · Score: 2, Interesting

    The "bootchart" tool mentioned in the article looks promising. But it's mostly unlabeled bars. Until they figure out how to correctly identify all the processes running during boot, it's not too helpful.

    The CPU utilization during booting is much higher than I would have expected. That's interesting, and unexpected. For most of the first ten seconds of post-kernel startup, the system is CPU bound, while the disk is idle more than half the time. Where is all that CPU effort going?

  4. How about 1.1 seconds to the bash shell? by dattaway · · Score: 2, Interesting

    If it can be done on a 200MHz ARM9 processor in just over a second, anyone else can do it:

    http://www.embeddedarm.com/epc/ts7400-spec-h.htm

  5. Re:An Uninformed Question by CastrTroy · · Score: 3, Interesting

    Or maybe he's just counting the time until the computer is actually usable. With Linux once the computer is booted, and you see the desktop, it's ready to use. With windows, it takes another 20 seconds (at least) after the desktop appears for it to actually become usable.

    --

    Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
  6. Re:launchd by spoonist · · Score: 2, Interesting

    Replying to my own post? Nice. I found this comparison between upstart and launchd. Long story short, launchd isn't event driven.

  7. Re: Boot time not an issue on my Mac by Anonymous Coward · · Score: 1, Interesting

    Ma notebooks now use Safe Sleep, which is kind of a hibernate/standby hybrid. When you put it to sleep, it writes the RAM contents to disk as if it was hibernating, and that can take a few seconds depending on how much RAM is in use. Unlike hibernation, when you wake, it wakes instantly because it doesn't go to the RAM image on disk unless there has been a power failure during sleep. It just resumes from whatever was in RAM at sleepytime.

    This best-of-both-worlds approach actually makes it possible to change the notebook battery without an internal backup battery, and yet not lose your session. When you resume after a power cut, it loads the RAM image from disk and all your apps are as you left them running.

    But if I do have to do a cold boot, my Mac Pro reaches the desktop in 15 seconds. I am not a Linux user but I certainly hope that Linux has optimized startup with caches by now. (If I make a major change to the system, such as an update or add/remove kernel extension, startup takes much longer as the caches need to be rebuilt.)

  8. Lots of always-on selfishness by linvir · · Score: 3, Interesting

    Anybody else appalled by the amount of people saying "just don't turn it off"?. I know I am. It's shocking for various reasons:

    1. It's an unnecessary, unethical waste of energy.
    2. It's an unnecessary security risk to leave so much of your sensitive data connected to the internet completely unattended.
    3. If you do get compromised, there is then the ethical issue of the amount of spam/DDoS your box can be used for by the time you realise what has happened.
    4. It's a poor solution to the problem of long boot times. A better solution would be to man up and learn some fucking patience.
    5. It uses up your machine's useful lifespan much more quickly at no significant gain to you.
    6. It's yet another electrical appliance always on and always ready to set off your smoke alarm or even start an electrical fire.

    If you leave your computer on 24/7 just for convenience, then perhaps you ought to consider the possibility that you are a spoilt rich selfish pussy and not the infallible sysadmin you undoubtedly believe yourself to be.

    1. Re:Lots of always-on selfishness by Aliencow · · Score: 2, Interesting

      1. It's an unnecessary, unethical waste of energy.
      I pay for my hydroelectricity thank you very much. I use CFLs and wash my clothes with cold water.

            2. It's an unnecessary security risk to leave so much of your sensitive data connected to the internet completely unattended.

      Oh yeah, if my machine is easily hackable, leaving it on 12 hours a day instead of 24 will make a huge difference.

            3. If you do get compromised, there is then the ethical issue of the amount of spam/DDoS your box can be used for by the time you realise what has happened.

      I haven't. And if I did, I'd notice, and if I didn't notice, my ISP would bill me for the bandwidth and then I'd notice pretty fast.
            4. It's a poor solution to the problem of long boot times. A better solution would be to man up and learn some fucking patience.
      It's not a solution to long boot time. It's a solution to keeping it online to download stuff, monitor stuff..
            5. It uses up your machine's useful lifespan much more quickly at no significant gain to you.
      I'm not sure...warming up and cooling down must not be all that good for the components.

            6. It's yet another electrical appliance always on and always ready to set off your smoke alarm or even start an electrical fire.
      That is one reason I never leave my laptop on alone though.

  9. No problems for the most part. by FunWithKnives · · Score: 2, Interesting

    I am running Kubuntu 6.10, and I have to say that I have been pleasantly surprised with Upstart, for the most part. It really is much quicker than the older boot sequences, as well as Windows XP, in my personal tests. I still have a couple qualms, however.

    The lack of a method to switch back to the traditional, detailed boot sequence is annoying. Editing /boot/grub/menu.lst and commenting out "quiet splash" takes care of it, but I don't always want to perform a status check when booting. This is a really simple thing to provide accomodation for, and I may just be unaware of a more simple solution that is already in place. If anyone knows of one, please enlighten me.

    The other problem comes as a result of the first. There is, with no option to switch to a detailed boot sequence, also no way to skip network detection. I am used to just issuing 'Ctrl+C' to skip it, and so it is quite frustrating sometimes. If you aren't connected to a network, or if you connect only after you have brought the system up, you are stuck waiting however long the default timeout is, unless you, again, perform a manual edit. This wouldn't be so much of an issue if arguments could be passed by default at boot-time, but as far as I know they cannot.

    Once again, if anyone knows of solutions to these issues that I am ignorant of, I'd be grateful to hear them. Other than what I have related, though, K/X/Ubuntu 6.10 boots very quickly, and I am quite happy with it.

    --
    "We may face a scorched and lifeless earth, but they're accountable to their shareholders first."
  10. Seriously, what about Windows booting by Proudrooster · · Score: 1, Interesting

    I know this is off-thread, but is there anyway to speed up Windows booting? At least with Linux you can tune and serialize or parallelize the boot process for speed. Is there anyway to do this with Windows? The 35 processes that launch out of my system tray just don't want play nice together on boot :)

    Sorry for the offtopic, but this is a sincere post.

  11. Linux boot time? How about hardware startup! by Ed+Random · · Score: 3, Interesting

    All in all, playing with parallelized OS startup is very nice but the real problem lies elsewhere...

    In my experience (data center, 350+ Intel-based servers, Linux + Windows plus a bunch of SPARC Solaris boxes), the OS boot time is negligible compared to the time needed for hardware initialization:

    - BIOS startup
    - Memory check
    - Remote Console init (DRAC/XSCF etc.)
    - RAID Controller(s) init, disk spinup
    - RAID Consistency Check, volume initialization
    - Start Boot Sequence

    Especially the disk subsystems cause large delays - most time is spent waiting for the GRUB screen.

    Parallelizing the hardware initialization is where we could make some significant progress.

    --
    -- Gxis! Ed.
  12. Here's some more advice to counter FUD. by twitter · · Score: 1, Interesting

    You insult lots of experienced Linux users who do care about their machines booting several times slower than an XP pc.

    That's an insult to everyone's intelligence. There is no such machine, unless you have serious hardware problems and the present article is the "more power to you" that I mentioned. Many live CDs boot faster than XP and most installed distributions boot faster than that.

    You may have a laptop and you may be happy with "hibernating" it, but many of us need to power off PCs. An office PC I power on every day, my home's PC I power on and off when I get and leave home.

    You should happy be like me. I'm aware of the issue. Ultimately, if you care about power consumption you are going to get a laptop or desktop with reasonable power management. Test it out before you buy it or send it back if you can't and it does not work. Microsoft continues to design complex and "extensible" non standards for power management, so it's not easy. Comfort yourself by knowing that M$'s dirty tricks make things harder for their own users than they are for you.

    Of course, there are benefits to having at least one machine that you never turn off and that never sleeps. I have contact information, archives of photos, music, movies and work that I can get to anywhere by sftp and KDE makes it all look local. This is much easier than syncing three or four laptops and desktops. Wake on lan might be nice, but my equipment is all so old, I've never bothered trying. For at least one machine, I never will. A modest server consumes 50 watts or less, kind of like some light bulbs I never turn off. I get more use by far out of the servers than I do light bulbs. Your business might also consider that a reasonable convenience.

    --

    Friends don't help friends install M$ junk.

  13. Re:An Uninformed Question by massysett · · Score: 2, Interesting

    Or maybe he's just counting the time until the computer is actually usable. With Linux once the computer is booted, and you see the desktop, it's ready to use. With windows, it takes another 20 seconds (at least) after the desktop appears for it to actually become usable.

    For my machine and GNOME, not true. GNOME goes through its splash screen and shows a desktop, but it is still loading panel applets and the clock. It takes several more seconds. It's hardly usable because loading anything while it's at this stage takes forever.

    I used to think KDE starts slower than GNOME. Now I think it's a dead heat. KDE shows its splash screen and it's there longer, but KDE is almost (if not entirely) done loading when it says "KDE is up and running." GNOME seems to take the Windows approach: show the desktop to fool 'em, even though it is actually still loading.

  14. Re:Ubuntu already uses Upstart by Anonymous Coward · · Score: 1, Interesting

    The full implementation of upstart isn't in Ubuntu yet- It was delayed until Feisty +1. So yes, upstart can still be much faster than it is now.

    See http://ubuntuforums.org/showpost.php?p=2264992&pos tcount=8

  15. Re:Popular FUD. by izomiac · · Score: 2, Interesting

    How about duel boot laptops? After all, Linux's hardware support for laptops isn't that great, and many people still have things they need (or prefer) to do in Windows or some other OS. Hibernation doesn't remount partitions, so guess what happens if you hibernate, boot another OS, edit a file, then resume?

    If boot time didn't matter then people wouldn't complain about it. You could hibernate all the time, but hibernation isn't perfect (or safe in all situations), and some people just like to start with a "clean slate" in the morning. Boot time is actually one of the big things that keeps me from using Linux very often. When I wake up in the morning and want to check my RSS feeds I have three options. First I turn on my laptop (which is off to conserve energy, prevent my P4 from acting like a space heater for my dorm room, keep the room quiet, and cut down on EM interference that keeps my "atomic" clocks from syncing), and get to my boot manager. If I choose BeOS (my primary OS) I can wait 30 seconds for the OS to load (since I'm stuck with 1 MB/sec disk read speed, normally it would be ~7 seconds), immediately launch Firefox in ~5 seconds (same problem) and I'm done. If I choose Windows I wait about 40 seconds for my desktop, and about 20 seconds for Windows to finish so I can launch Firefox. With Linux I have to wait 2 - 3 minutes for it to boot and I can launch Firefox immediately. Hibernation wouldn't work since I use one Firefox profile on a shared drive.

    So, even though hibernation works for you, it's not a valid excuse for an unnecessarily long boot time. (Oh, and if you're wondering why I still use the BeOS despite crappy hardware support, it's because it tends to be an order of magnitude faster for opening folders, e-mail, and non-ported applications. I get pissed off if I have to wait for a program and there isn't a hardware or network bottleneck that's causing the delay.)