Slashdot Mirror


Booting Linux Faster

krony writes "IBM's DeveloperWorks explains how to decrease boot times for your Linux box. The concept is to load system services in parallel when possible. Most surprising to me is the use of 'make' to handle dependencies between services." The example system shown is able to cut its boot time in half, but the article stresses the effectiveness can vary widly from machine to machine.

98 of 625 comments (clear)

  1. Predicted response by Anonymous Coward · · Score: 5, Insightful

    "Who cares how long it takes to boot Linux? My uptime is 400 days!!!"

    Yup.. just keep talking about that and wonder why Linux never becomes mainstream.

    1. Re:Predicted response by Anonymous Coward · · Score: 3, Funny

      Yup.. just keep talking about that and wonder why Linux never becomes mainstream.

      Because mainstream means rebooting every day! Twice on Sundays.

    2. Re:Predicted response by homer_ca · · Score: 2, Insightful

      The whole reason behind the success of Linux has been the friendly and responsive user and developer community. You want to talk about arcane commands and a smug attitude about technical superiority, just look at the BSDs. Technically, they were way ahead of Linux for years since they had an existing stable codebase, and they're still developing lots of good features for servers, but the user friendliness has never advanced past Slackware.

    3. Re:Predicted response by Crispy+Critters · · Score: 5, Insightful
      "This is the current state of the Linux community."

      No it isn't. I am on a local LUG mailing list, and people are politely helping newbies all the time, going out of their way to explain things that weren't even asked, just in case it might help.

      "Not only the case on Slashdot, but go to any IRC help channel and you'll find the same the majority of the time."

      IRC and /. were not exactly designed for thoughtful interaction.

    4. Re:Predicted response by Trepalium · · Score: 5, Insightful
      In order for him to get a straight answer he had to pre-emptively insult himself "Guys, I know I'm entirely retarded, but does anyone know how to get mplayer to play X?"
      Uhm, so you think that just because someone insulted himself during the post means that everyone who might provide you with free technical support on Linux is a prick? Hate to break this to you, but that's hardly Linux's fault. Regardless of what you look for support on, you'll find idiots who want to give you snide comments like RTFM, or go do it yourself. My experience is that most people will try to help you provided you show that you made some effort to solve the problem yourself (such as state what you tried that didn't work).

      Lets assume that you call a vendor for support. You'd likely to have paid for the support, so the vendor will likely allow you to be somewhat abusive of their support personelle because the money you pay them is worth the inconvenience. Now, most of the support you get on newsgroups is by people not getting any income for answering your questions, so their tolerance to put up with crap is significantly decreased. If you even ask a question in such a way that makes you look like you might be one of the assholes they deal with in the support business, you will be dropped as quickly as possible. When you want something for nothing, being polite and courteous versus appearing to bark out demands is the difference between getting an answer, and getting "RTFM". BTW, this applies equally to proprietary software lists (unmanned by paid employees) as to free software lists. Lists and discussion groups with paid employees answering questions (such as microsoft.public.*) can be friendlier, but you get boilerplate responses more often, and the same answer three times over before someone finally gets that their solution doesn't work for your problem.

      --
      I used up all my sick days, so I'm calling in dead.
    5. Re:Predicted response by mangu · · Score: 4, Interesting
      The problem was "There is a sense of snideness in the Linux community, and trying to ask for support is one of those examples of snideness."


      I think this "problem" you mention is some sort of urban legend. I have heard this same argument countless times, but I have never actually seen this happen. I have been a subscriber to a few Linux mailing lists for several years now, and I have never actually seen someone post "RTFM" as an answer to a question.

      Myself, I try to sort of evaluate the person who is asking for help. If I think he has an adventurous soul, and is willing to go through a lot of documentation, I try to orient him to the relevant how-to's. In the other hand, if I feel the person is somewhat impatient, I recommend a Mandrake installation, since it's the most likely to get the user safely past the most annoying problems with minimum fuss.

    6. Re:Predicted response by ftzdomino · · Score: 5, Funny

      What really sucks is the 497.1 day uptime rollover bug. Apparently it has been fixed, but that doesn't help us who booted before it.

    7. Re:Predicted response by bluGill · · Score: 2, Funny

      I'd show you the uptime of my mailserver, but it is loaded enough already. Anyone care to guess how long it takes for a 386 with loads > 8, to respond to an uptime request? It ain't pretty I'll warn you in advance.

      That machine has been due for retirement since before anyone mainstream worried about y2k, but I've never got around to it and the 80MB harddrive hasn't crashed yet.

    8. Re:Predicted response by AstroDrabb · · Score: 5, Informative

      This isn't true. I am one of the moderators for Red Hat @ yahoo and I am very active in Linux @ Yahoo. Join up. We are very kind over there. We only ask that

      1. No top posting
      2. No broken mailers that don't thread well (Outlook/OE)
      3. Learn to search www.google.com.

      I never see people getting into flame wars. The same thing goes for most LUGS. Come to one of the Yahoo groups and join up : )

      --
      If Tyranny and Oppression come to this land,
      it will be in the guise of fighting a foreign enemy. -James Madison
    9. Re:Predicted response by irc.goatse.cx+troll · · Score: 3, Insightful

      You're vulnerable to the ptrace exploit, among others.

      The key to reliability is not uptime but redunancy. I'd rather have an array of 10 servers with 20day uptimes each cycling their reboots than on server with a 200day uptime suffering from old vulnerabilities and other problems that come with age.

      --
      Pain lasts, kid. Its how you know you're alive. Sometimes I think this growing up thing is just pain management-TheMaxx
    10. Re:Predicted response by cygnusx · · Score: 3, Insightful

      > Learn to search www.google.com

      I agree, but the users who need help *the most* don't even know what to search for.

    11. Re:Predicted response by kelnos · · Score: 4, Insightful

      seriously... after reading through a bunch of these posts, i see soooo many "why do i care how long it takes to boot up? i just boot it and leave it for a year." a few are joking, but most are just ignorant idiots. sure, there are some of us (myself included) that don't turn off their machine (i probably would to save on the utilities bill, but i host websites for a few student orgs at my school, among other things). anyway, there are _plenty_ of people that could make a faster boot useful. laptop users, for one. people that only use their computers for a few short tasks a day, and turn it off. people that don't need to run it overnight for whatever reason, and actually like the idea of saving a little energy.

      get a little perspective, people. ignorance is so first millennium...

      --
      Xfce: Lighter than some, heavier than others. Just right.
  2. Another way to speed up booting Linux by Anonymous Coward · · Score: 2, Insightful

    Develop a better initialization sequence. Relying on a scripting language, such as bash, to initialize each system component slows down bootup time. Instead design a standard such that daemons can be stop/started/restarted with a standardized set of command line options.

    1. Re:Another way to speed up booting Linux by pudding7 · · Score: 5, Insightful

      Anyone ever wonder how we got ourselves into a situation where we spend so much time saving ourselves time?

    2. Re:Another way to speed up booting Linux by Concerned+Onlooker · · Score: 2, Interesting

      It's just human nature. Douglas Adams wrote in "Last Chance to See" that he would glady spend an hour working on a way to save himself ten minutes on the computer.

      --
      http://www.rootstrikers.org/
    3. Re:Another way to speed up booting Linux by Anonymous Coward · · Score: 3, Funny

      If Douglas Adams is so damn smart, why is he dead?

    4. Re:Another way to speed up booting Linux by sfraggle · · Score: 2, Informative

      This is a blatant troll. The current init.d scripts system IS a way to start and stop daemons with a set of standard command line options. Realistically, there isnt any noticable performance hit from using bash scripts, especially considering the scripts used to start system services are usually incredibly simple.

      --
      were you expecting to see a sig here? perhaps you'd rather see the inside of an ambulance!
    5. Re:Another way to speed up booting Linux by shellbeach · · Score: 2, Insightful
      ... or simply don't run the services you don't need? Distros try to please all the people all of the time. That doesn't mean you need to run half the stuff that's provided.

      A very interesting experience for me was starting from scratch and only *including* the stuff I needed when playing around with a minimal linux distro (crux linux). You'd be amazed how much crud you don't need and how much faster the system boots ...

  3. Yeah, right! by rocjoe71 · · Score: 4, Funny

    Like any Linux user is gonig to reset their uptime just to see if they can boot faster!

    --
    Height: 38U, Weight: 0 Newtons, Eyes: #0000FF, OS: Gray Matter 1.0 (Alpha)
  4. I don't have a computer to boot... by Atmchicago · · Score: 3, Funny

    you insensitive clod!

    --

    You can lead a horse to water, but you can't make it dissolve.

  5. Timely by pete-classic · · Score: 2, Redundant

    I had a conversation with my Dad about Linux start times yesterday that went something like:

    Dad: But it takes so long to start up.

    Me: Yeah, but you only have to do it once.

    -Peter

    1. Re:Timely by Arker · · Score: 2, Insightful

      Why is it taking long to boot up? That's not my experience. Loading a lot of services?

      --
      =-=-=-=-=-=-=-=-=-=-=-=-=-=-
      Friends don't let friends enable ecmascript.
  6. Make? by JohnGrahamCumming · · Score: 5, Insightful

    Most surprising to me is the use of 'make' to handle dependencies between services."

    Really? That's an odd statement. How surprising that they choose to use an open-source software application that is designed to compactly represent dependencies for representing dependencies.

    Perhaps they should have drawn Visio diagrams instead!?

    John.

    1. Re:Make? by clem.dickey · · Score: 4, Interesting

      Not having looked at the code, it seems to me that make would only handle half the problem: booting. Shutdown is the other half; the dependencies would be reversed. For example:

      For boot you would tell make this:

      sshd: network
      rpcd: network

      But for shutdown you need to tell it this:

      network: sshd rpcd

      Ideally one set of input data should take care of both cases.

    2. Re:Make? by MBCook · · Score: 2, Interesting
      I thought it was suprising at first. Yes, that is what make is designed to do, but I'd think most people (myself included) think of make as a programming tool. I don't think I would have thought about using make for that job, at least not at first.

      This isn't make's intended use (it was designed for programming), so it's a bit suprising to see it used this way at first.

      That said, it does make perfect sense.

      --
      Comment forecast: Bits of genius surrounded by a sea of mediocrity.
    3. Re:Make? by The+Pim · · Score: 2, Informative
      How surprising that they choose to use an open-source software application that is designed to compactly represent dependencies for representing dependencies.

      Surprising to most people, because they don't understand what make is. There's a well-known paper that tries to explain what make is and how to use it effectively. As it says, "Make is an expert system". Meaning, you give it a bunch of rules, and it tries to get you to your goal. Make would get a whole lot less flack if people understood this.

      Not that make is all that great an expert system: it has tons of warts and limitations and misfeatures. But most of the would-be make replacements solve the wrong problem. They ask, "how can I get my software to build with less fuss?" instead of, "how can I design a better expert system?".

      --

      The evaluation of an action as 'practical' . . . depends on what it is that one wishes to practice.
    4. Re:Make? by svu · · Score: 3, Funny

      Visio?! Easy! You take Visio 2003. Generate XMI. Then - apply some XSLT stylesheet to create build.xml for the ant tool. Then use ant instead of make as startup tool. So you got visual design for you startup sequence!

    5. Re:Make? by slamb · · Score: 4, Interesting
      > > Most surprising to me is the use of 'make' to handle dependencies between services."

      > Really? That's an odd statement. How surprising that they choose to use an open-source software application that is designed to compactly represent dependencies for representing dependencies.

      Actually, I also found it surprising, and I think I know "make" pretty well. The thing about make is that in 95% of cases almost all of the rules correspond to an actual target file that should be generated or not based on presence and timestamp. There are exceptions, like the usual "all" rule that's called a phony rule since it generates no file. (And make sure you have a ".PHONY: all" line right before it or "touch all" will break your build.) It's usually just there for the dependencies on a bunch of real targets, so you don't have to type "make this && make that && make ...".

      Parts of make that they're not using here:

      • logic for checking if a real target is up-to-date
      • rules for creating specific targets from generic ones, like the .c.o target
      • variable substitutions
      • a lot of other things...look at the man/info pages; modern versions of make have a lot of functionality that makes no sense here
      And they are using:
      • topological sort (easy algorithm!)
      • stuff for following the partial order in parallel (also surprisingly easy)
      • the parser, but it's for a widely-disliked syntax that doesn't make a lot of sense here

      When I say the syntax doesn't make sense here, I mean (in addition to the usual make complaints) that it's all in one file. Distributors (notably RedHat in particular) have been very serious about separating out stuff into .d directories so that packages don't need to touch each others' files.

      So, I think make is the wrong tool for the job here, at least in the long term. A simple tool with separate files for each service would be a win. I don't think the author of the article really cares about that (it's just a little tip for intermediate users), but if a distribution wanted to implement this idea and maintain it, they wouldn't use make.

    6. Re:Make? by Jellybob · · Score: 3, Insightful

      I can understand the most blindingly obvious things being surprising.

      If you were to drop someone with no knowledge of electricity into a room with a switch, and they flicked that switch, they'd be surprised when the light comes on, despite it being "obvious".

      And that's because things are only obvious once you know them, right up until that point, they're just an unsolved problem.

    7. Re:Make? by cjj2 · · Score: 2, Informative

      make has an include statement, so you can do the separate-file-based configuration. Additionally, the file that is included is considered as a target, so you could write a rule that generates the included file; e.g., you could generate a nested include statement that picks up all the files in a given directory.

    8. Re:Make? by Webmonger · · Score: 3, Informative

      Actually, Makefiles don't have to be single monolithic files. GNU make supports the include command, which takes wildcards.

      So in MakefileRC5, "include /etc/makerc5.d/*" would include all the makefiles in the specified directory. Such makefiles would be lpd.mk and ntpd.mk, etc.

      I think that might actually work!

    9. Re:Make? by Feztaa · · Score: 4, Insightful

      I think it's clever, because (possibly) nobody ever thought of doing it before. Make is a tool that makes it easy to compile programs, not for booting your system.

      I've heard that a program isn't truly successful until it's been used in a way unimagined by the original author. I guess make is now truly successful :)

    10. Re:Make? by Dr.+Photo · · Score: 3, Funny

      If you were to drop someone with no knowledge of electricity into a room with a switch, and they flicked that switch, they'd be surprised when the light comes on, despite it being "obvious".

      And if the light were a nice bright halogen lamp, it might even be blindingly obvious!

      (Terribly sorry.. couldn't resist...)

    11. Re:Make? by Anonymous Coward · · Score: 2, Insightful
      For most make programms (certainly GNU make)

      network: sshd rpcd

      is equivalent to

      network: sshd
      network: rpcd

      with is very easy to create from

      sshd: network
      rpcd: network

  7. Just turn off services you don't need by Anonymous+Crowhead · · Score: 5, Informative

    I did that on an old slow laptop, and it cut the boot time quite a bit. There is plenty of stuff that you might not need to run like kudzu, lpd, portmap, sendmail, sshd, or clock syncing stuff.

    1. Re:Just turn off services you don't need by Michael+Woodhams · · Score: 3, Interesting

      Something for the usability folks to think about:

      Ordinary users, and even many geeks, don't have time to figure out what every service does and whether they use it. A policy of aggresively turning off services (mostly for security, partly for boot time) carries a risk of turning of a service that is needed.

      I suggest that there should be a standard framework for dealing with "a needed service is not running" problems. On a desktop Linux, this should pop up a window explaining what service wasn't running, and giving options to do nothing, start the service on a one-time basis, or add the service to boot time start-up (and prompting for root password as required.)

      (There can be extra options - don't start the service, and never ask me again. Don't start the service, and never ask me again if this particular program complains about it.)

      --
      Quattuor res in hoc mundo sanctae sunt: libri, liberi, libertas et liberalitas.
  8. Other things to speed up boot time by epiphani · · Score: 5, Informative
    These may seem obvious, but if you're after a quick boot, try doing these things:

    • Recompile the kernel with bare essentials only - monolithic.
    • Turn off non-essential non-inetd services.
    • Tweek your rc.d scripts to get rid of things like modprobe calls.
    • Dont boot directly to xdm if you dont have to.


    Personally, I dont give a shit about how long my linux machines take to boot up, because they dont go off once they're up.
    --
    .
    1. Re:Other things to speed up boot time by oever · · Score: 2, Interesting
      These are all good suggestions. There are two reasons one'd like to reduce boot times:
      • You're running an important server
      • You're booting your computer daily because you only really use it 1/3 of the time and don't want to waste electricity.

      If the second reason is your main reason to boot quickly, you'll probably want to start X too every time you boot. So waiting to start X until a user says X should be started is no option. Your other suggestions are spot on.

      If you'd like to take away the last, big, bottleneck, it would be a good idea to start X in parallel with the other, independant, services. This is exactly what's described in the insightful IBM article. Hooray!

      --
      DNA is the ultimate spaghetti code.
    2. Re:Other things to speed up boot time by ysachlandil · · Score: 2, Informative

      Flashing linux into BIOS:

      www.linuxbios.org

      current record: 3 seconds!

      --Blerik

  9. Isn't there a way by SHEENmaster · · Score: 2, Interesting

    to reboot without rebooting, such that uptime remains the same but kernel upgrades can take place?

    I remember reading about it somewhere, but it was skimpy on details, sufficing to say that it was a "bad idea".

    --
    You can't judge a book by the way it wears its hair.
    1. Re:Isn't there a way by irc.goatse.cx+troll · · Score: 2, Informative

      I remember a few of the details. It involved overwriting the kernel thats live in memory while its still running. I dont remember if it was linux or some bsd that it was done with, but I know its worked for some people. Its just a huge risk, and not really worth it -- reliability isn't uptime.

      --
      Pain lasts, kid. Its how you know you're alive. Sometimes I think this growing up thing is just pain management-TheMaxx
  10. Re:Hmm by 4of12 · · Score: 4, Insightful

    someone has a use for this

    You bet.

    How long are you willing to wait for your stereo receiver to boot up, your TV, or your TiVo?

    This is a really important issue for embedded devices like consumer electronics built on Linux.

    --
    "Provided by the management for your protection."
  11. Does it really take that long? by pclminion · · Score: 2, Informative
    I still remember the days when I installed Slackware off floppies, and unless my memory is failing much faster than anticipated, I don't think the kernel itself takes much longer to boot than it ever did.

    What definitely does take longer is starting all the system services. I know that an out-of-box RedHat installation starts an insane number of (mostly useless) services on startup. The first thing I always do when installing a RH box is run 'ntsysv' and disable all the crud.

    The 'kudzu' utility is the worst offender. It checks the system for any new hardware or peripherals. There's no need for this to run on every single boot!

    And BTW... Why are you rebooting a Linux box anyway? ;-)

  12. The Real Question by rowanxmas · · Score: 2, Funny

    Because it must be asked....

    How much time is saved when booting up a beowulf cluster?

  13. Serel by ensignyu · · Score: 5, Informative

    Serel does this too, for RedHat and Debian. It actually works; it's not just a proof-of-concept, although it does have a number of bugs.

    1. Re:Serel by gmhowell · · Score: 4, Informative

      It may not be a proof of concept, but it seems to be a beta that hasn't been touched in a year. And debian packages (on the site I looked at) aren't available, only rpms.

      Still, looks nifty.

      --
      Jesus was all right but his disciples were thick and ordinary. -John Lennon
  14. Re:Faster Booting by taxtropel · · Score: 2, Insightful

    9 second boot time from power-up to X-windows

  15. FastBoot.org? by nickread · · Score: 2, Informative

    Isn't this basically the same thing (different implementation though).

    http://www.fastboot.org/

  16. Re:boot? by kcurtis · · Score: 5, Insightful

    > I rarely have to boot ever after the first boot and patch!

    Probably true. But one goal of linux is to become the predominant desktop/laptop OS.

    I work for a public school system. I'd rather not have all these computers eating up power all night when they're not being used.

    In most work environments, pc's get turned off over night, and sometimes even at lunch.

    This is one more way someone is helping to make Linux a better candidate for your casual end user.

  17. Spooky by JayJayEm · · Score: 2, Informative
    I was just thinking about this after reading the excellent whitepaper on Microsoft.com (don't laugh) at http://www.microsoft.com/whdc/hwdev/platform/perfo rmance/fastboot/fastboot-winxp.mspx

    You should be able to extract the word document using a zip utility.

    It describes in quite a lot of detail how they reduced boot time in XP (not only starting stuff in parallel but also prefetching and other tricks).

  18. This is actually important by augustz · · Score: 4, Insightful

    I see there are already a ton of linux fanboys and girls posting about the incredible uptime of their linux boxes, and claiming that a) boot time doesn't matter because linux doesn't go down or b) linux boots very fast.

    They are wrong. Boot time matters.

    It matters for perception. Boot time is one of the periods where a user spends the most time looking at a screen not being able to do anything (even if that happens rarely). A faster boot time leads to a sense that the whole system is faster, because it is a first impression, and a significant impression. If linux bliped on from a cold start in 5 seconds, I'd be studies would show it appeared faster.

    Boot time matters because not everyone (in fact, very few people) leave their systems on all the time. Slashdot fan boys living at home may not agree, but they are wrong.

    Think about business systems. At my place of work, everyone turns their computer off at the end of the day, and on at the beginning of the next. My mother doesn't leave her computer running 24/7, she turns it OFF when she is done using it. My roomates do the same thing. Even I do it sometimes.

    Boot time matters because power management is still evolving under linux. As power management requires the cooperation of a number of pieces of a system, power management is still a work in progress. Once power management with every peripheral is flawless, then we can start to dial back boot time worries (only a little).

    Boot time matters server side too. I know folks are going to complain that I focus on the user too much. But boot time matters server side as well. We have UPS units on our servers. They have however a limited lifetime. So when the power drops for a few minutes (which it does here somewhat often) automatic shutdown process starts.

    When the power comes back on, people power up their computers. These being Windows XP machines they actually start pretty quickly (or never went off if on a UPS). If folks were in the middle of something, they expect that with the power their logon and other services will be back in action. Then all the individual computers start timing out / locking up, generating help calls.

    On the server side, if there was an emergency security patch, or we were coming up from a power outage, the faster the boot time the better, if I can beat out even 20% of the client connect attempts.

    Boot time matters, a big bravo to the folks working to improve this.

    1. Re:This is actually important by John+Hurliman · · Score: 4, Informative

      A lot of comments also missed a major platform, laptops.

      I've been furiously tweaking out my Averatec to get the quickest possible bootup (and shutdown); everything from a highly customized 2.6.0 kernel, to experimenting with software suspend and custom startup scripts. Right now I have my system booting the bare bones necessary services to get me in to X so I can turn the laptop on and fire up OpenOffice in class. The rest of the service launching is done with a shell script that I call after booting if I want to do more, like get on the net, use Samba or print.

    2. Re:This is actually important by nivedita · · Score: 2, Informative

      You didn't have to write your own script: sysvinit has a concept of runlevels with 1 for single-user, 2 for multi-user without net, 3 for multi-user net and 5 for X. Gentoo linux takes this even further: you could have an arbitrary number of runlevels with mnemonic names.

    3. Re:This is actually important by int2str · · Score: 2, Interesting

      What's wrong with Suspend/Resume? Powering off your notebook seems like a waste of battery and time if you ask me.

      I would even start to apply this to desktop machines - just suspend it, don't turn it off all the way.

      Cheers.
      Andre

    4. Re:This is actually important by mgkimsal2 · · Score: 2, Informative

      It doesn't work with most laptops, that's why not.

  19. Re: "you only need to boot it up once" by vlad_petric · · Score: 4, Informative

    I'm afraid that if you have a laptop, boot time is quite important. Doing suspend/resume with X running is not reliable. While I certainly agree that fixing this is the long term solution, a quicker boot-up is a reasonable fix in the meanwhile

    --

    The Raven

  20. Re:LONG LIVE IBM! by Sphere1952 · · Score: 2, Funny

    What? You don't have a battery?

    Geeze. How the Hell do you set the clocks in your house? Call time?

    --
    Big Brother Bush is doubleplus ungood.
  21. Re:Hmm by Obasan · · Score: 4, Interesting

    As someone who uses linux on a laptop, running SuSE 8.2 I *DEFINITELY* have a use for this. I use my laptop in a professional capacity to do quite a lot of things, and while I can run on batteries I do generally turn it off and on at least a couple times a day. Further - because I am occasionally forced to dual boot, sometimes that can be even more often. It is a good 3-4 minutes between power on and KDE desktop. This is on an 800mhz P3 with 512 megs of RAM.

    Do I want a faster boot?

    You bet your ass I do.

  22. why not start them all at once by TornSheetMetal · · Score: 3, Insightful

    Since you have to work out the dependices yourself, why not imbed the dependices in the startup scripts themselves? So for example, the nfs startup script would block until the network script got started. The status can be checked by parsing /etc/rc.d/init.d/network status. You may want a timeout on the blocking. If you do this you could just start all the scripts at once.

  23. PowerPC Linux users had compiled boot 'scripts' by Sleepy · · Score: 5, Interesting

    This was three years or more ago, but I remember one of the PPC Linux developers "converted" all his system boot scripts in init.d to compiled C.

    Boot times went from about 2 minutes, to 35 seconds.

    (It took "so long" because it was an old PPC 601 60MHz or something like that).

    Distributions such as Mandrake and Gentoo claim they go the extra mile for "performance". I've wondered why neither has cleaned up their boot process.

    You wouldn't think Bash is slow from interactive use, but it really it. Piggyback on that speed problem that too many "functions" (OK, *commands*) are standalone executables... greate sub-process, collect result, destroy, rinse repeat.

    This is pretty interesting stuff, and I applaud this guys efforts. INIT script achitecture is pretty thankless stuff.. .no "glory". Fixing this would be like someone fixing fdisk... no one wants to touch the damn stuff...

    1. Re:PowerPC Linux users had compiled boot 'scripts' by Master+Bait · · Score: 5, Interesting
      That's a pretty good idea.
      I use a bunch of homemade Xterminals made out of Nforce boards and we have replaced /sbin/init itself with an executable shell script (and use ash for the shell instead of bash). The entire contents of init is this:
      #!/bin/sh
      /bin/cat /dev/null > /var/run/utmp
      /sbin/insmod /modules/nvnet.o
      /sbin/ifconfig lo 127.0.0.1
      /sbin/mount -o remount,rw /
      /sbin/mount -t proc /proc /proc
      /sbin/insmod /modules/nvidia.o
      /usr/X11R6/bin/X -broadcast
      /bin/sh

      No shutdown script is necessary because Xterminal users simply logout and turn them off.

      I think one of the biggest slowdowns on PCs is the lame PCBIOS which takes a very long time to run through all the hardware. I remember following LinuxBIOS development. It is so fast, that it was finished checking the computer's hardware before the disk drives finished spinning up.

      --
      "Only in their dreams can men truly be free 'twas always thus, and always thus will be."
      --Tom Schulman
    2. Re:PowerPC Linux users had compiled boot 'scripts' by Monkelectric · · Score: 2, Informative
      Gentoo claim they go the extra mile for "performance"

      My *cheap ass* Athlon 1700 gentoo box (total system value: 300$) can *reboot* gentoo in under 30 seconds, INCLUDING X. What else do you want?

      If your linux box takes more then 30 seconds to boot up you are either A: running way too many services, B: You're running Mandrake/Redhat (in which case you're guilty of A to).

      --

      Religion is a gateway psychosis. -- Dave Foley

    3. Re:PowerPC Linux users had compiled boot 'scripts' by LocoBurger · · Score: 2, Informative

      Gentoo has gone a long way towards faster booting already. It doesn't have compiled boot scripts, but it has a much more sophisticated runlevel management system than is described in the article. It has real dependencies and whatnot, and boots very very quickly.

      Here is Gentoo's own explanation..

      Pretty swanky really, and very easy to use.

  24. Re:Hmm by MatthewB79 · · Score: 3, Insightful

    I think this will be useful only for desktops actually. Embedded devices do not usually run as many services as desktops. And the embedded Linux implementations seem to boot plenty fast as it is.
    For example, my Linksys WAP boots up in about 10 seconds.
    For a better embedded example, look at a Compaq iPAQ H3650 circa 3 years ago running Familiar Linux with the Opie desktop. It boots up in about 8 seconds. Then it's "instant" on/off unless you hard reset the device. It's also running more services than the default install.

  25. Parallel startup implemented in Mac OS X by MotownAvi · · Score: 4, Interesting

    Bah. Mac OS X's done this since Jaguar.

    The big question is "how do you specify dependencies?" The article uses makefiles. In Mac OS X, each startup item has a properties file (associative array) that names the item and specifies all the items that it depends on (http://www.usenix.org/events/bsdcon02/full_papers /sanchez/sanchez_html/). Then SystemStarter makes a dependency graph and starts them up in parallel whenever possible (http://developer.apple.com/documentation/MacOSX/C onceptual/SystemOverview/BootingLogin/chapter_4_se ction_2.html).

    1. Re:Parallel startup implemented in Mac OS X by klui · · Score: 2, Insightful

      You beat me to it. OS X also implements dynamic disk mounts even for root. Disks are mounted and assigned to a device on a first-come first-served basis.

  26. netbsd rc.d by Fritz_the_Cat · · Score: 5, Informative

    I'm surprised someone hasn't pointed this out already. NetBSD's rc.d.has had support for dependencies for sometime.
    http://www.netbsd.org/guide/en/chap-rc. html

    Additionally, there's an article here. http://www.daemonnews.org/200108/rcdsystem.html

  27. Gentoo can do that too by Anonymous Coward · · Score: 2, Informative

    Gentoo can do that too, just edit /etc/conf.d/rc:

    RC_PARALLEL_STARTUP="yes"

  28. Re:Dual (or more) cpus by vadim_t · · Score: 3, Insightful

    I've got a dual Athlon 2000+. The boot time improvement is next to inexistent. Overall it boots slower, due to the initial delay (about half a minute) to initialize ECC RAM, and the second or two Linux needs to initialize SMP.

    Now, it's definitely a really big improvement over a 1 CPU system.

    It's really smooth, and I can:

    Burn CDs at 24x and play Quake 3

    Compile programs using both CPUs and play videos at the same time.

    Kill high priority programs (like sound daemons) that went mad for some reason and got into an infinite loop. This happened me with KDE a few months ago. With 1 CPU my computer froze for minutes until it could react to my request to kill the daemon. With SMP, no problem, I still have an idle CPU.

    It's really nice for Gentoo. KDE compiles in several hours, and my computer isn't slowed down noticeably by the compilation. The basic Gentoo installation is done in a day, I can get all the necessary programs compiled during the second day.

    The hardware is really stable too. Never locks up, never crashes. ECC RAM gives great peace of mind, too.

  29. Apple did this in Jaguar by tim1724 · · Score: 4, Informative

    One of the things Apple did in Jaguar to speed up Mac OS X booting was to start services in parallel.

    Apple uses a different startup script system (see the references below) than other UNIX flavors, but it's a really cool system. It uses dependency information rather than carefully-assigned integers to determine load order, so when they decided to add parallel service starting it was easy .. the dependency information was already there.

    I'd love to see Linux or *BSD distributions adopt this system, as it's really cool to type SystemStarter start foo and have it automatically load all the dependencies for foo before starting foo itself. Plus adding services means just copying a directory into place .. no worrying about making links in /etc/rc?.d or getting the ordering right.

    Relevant documentation:

    --
    -- Tim Buchheim
    1. Re:Apple did this in Jaguar by nvrrobx · · Score: 2, Informative

      Oooh I know I'm going to get flamed for this.

      On a Windows box:

      net start w3svc

      That will start IISAdmin automagically too. :)

      Gentoo's init scripts have dependency checking too. Now, if they started in parallel.. Wheee! That would certainly rock for bootup time on my laptop.

  30. Re:Just use Jiffies by CausticWindow · · Score: 4, Funny

    Remember to turn back the uptime when you sell your computer.

    --
    How small a thought it takes to fill a whole life
  31. power down? Grid!! by LinuxHam · · Score: 2, Insightful

    And if you stick around long enough at DeveloperWorks, you'll make a grid out of those PCs and offer the district more compute power than they ever realized they had.

    --
    Intelligent Life on Earth
  32. Been there, done that by CausticWindow · · Score: 3, Informative

    Pah. Mac OS X have done this since 10.2.

    The large question is "how do you specify inter dependencies?" The article uses makefiles. In Mac OS X Jaguar, each startup item has a properties file (associative array, the indexes are strings) that lists the item and defines all the other parts that it depends on. Thereafter SystemStarter makes a dependency tree and starts them up in parallax whenever possible or when it feels like.

    --
    How small a thought it takes to fill a whole life
  33. Nostalgy by Peaker · · Score: 3, Informative

    I have started a discussion on Debian Devel about this quite a long while ago.

    It sure is nice to see that my idea is being implemented...

    However, as others mentioned there are quite a few problems with this approach.

    One, is that it is very difficult to use make to perform the reverse (shutdown) using the same input data as the boot.

    Another problem, one that I had no time to solve, and seems to not be addressed at all by the article, is that running services in parallel also logs things in parallel. Intermixed logs are quite unfriendly to read.

    The plan a few of us at Debian Devel devised was a mini-text-window-manager for the output logs, but noone got around to implementing it.

    Lastly, the most serious problem with this approach, was legacy support. Inserting this system into Debian, at least, required that all service package maintainers provide extra dependency information about their packages. This problem was the least feasible to solve.

    Thus, my little project died then - and seems to now be revived by IBM :)

  34. Very Discriminating My Friend by tds67 · · Score: 2, Funny

    JIFFIES

    This is an extremely simple patch for the 2.4 kernel. It creates a read/writable entry /proc/sys/kernel/jiffies, where you can get and set the current jiffies. To fake your systems uptime, write the required number of jiffies to this file :

    # echo 100000 > /proc/sys/kernel/jiffies

    Nice way to solve this problem. You really must have a refined sense of good taste, because only choosy mothers choose jiffies.

  35. That's exactly what I wrote minit for by Fefe · · Score: 5, Informative

    See www.fefe.de/minit/ for info about the project.

    It's a tiny statically linked init that besides offering make-like dependencies to load services in parallel also offers ways to avoid spawning a thousand shell and utility processes in the boot process.

    On my notebook, it takes less than a second from the start of init to a login prompt. In fact the latency is so small that I have never used the APM or ACPI suspend mode any more, I just turn the notebook off and on again. That's actually faster than the BIOS suspend-to-disk feature.

    minit also has other benefits over standard init: you can ask init for the PID of services like sshd without PID files and thus even on read-only media like a CD-ROM without initial RAM disk or shmfs.

    It's Linux only, though. And you need the diet libc for full effect (52k memory footprint for init on my desktop, including shared read-only pages).

  36. I've been doing it since 1999. by pr0ntab · · Score: 5, Informative

    My first linux Mandrake box, I went through and parallelized my rc directories. The trick was to have fake S** entries that spawn off what can be done in parallel.

    Albeit makefile based (done by hand), but I was getting my boot times down to 23 seconds on an aging Pentium MMX, with tons of unnecessary services. (I know better know, :-P)

    Too bad there wasn't any way I could have done that to Windows 98. It was a DOG!

    XP is much better, but it doesn't boot much faster than that fast on my new box even today.

    --
    Fuck Beta. Fuck Dice
  37. I got one down to about 3 seconds. by AxelTorvalds · · Score: 2, Interesting
    It was a Pentium 300 Mhz class machine in an embedded device. I had the kernel in flash and used my own variation of the linuxbios project.

    My best times were power on to init in about 2.7 seconds. By the time we got the "authentication code" and what not in it was closer to 30 seconds.

    Take all that BIOS stuff out and create a truely lean and mean setup with minimal init scripts and you can blaze. Longest step was copying the kernel from slow-mo flash memory in to RAM...

  38. Re:Predicted Predicted response by Karrots · · Score: 3, Interesting
    I know the Gentoo start up scripts can do this. Well I take that back I don't know if they actually do it. But they have a setting for it. As you can see mine is off at the moment.
    # Set to "yes" if you want the rc system to try and start services
    # in parallel for slight speed improvement.

    RC_PARALLEL_STARTUP="no"
  39. Linux DID adopt it. by Balinares · · Score: 2, Informative

    > I'd love to see Linux or *BSD distributions adopt this system,
    > as it's really cool to type SystemStarter start foo and have it
    > automatically load all the dependencies for foo before starting
    > foo itself.

    Gentoo has been working that way for years, and if Gentoo does it, there are certainly other distros that work that way as well.

    --

    -- B.
    This sig does in fact not have the property it claims not to have.
  40. Richard Gooch's method by ldamerow · · Score: 3, Informative

    Richard Gooch published an interesting implementation of parallel init scripts almost a year ago: http://www.atnf.csiro.au/people/rgooch/linux/boot- scripts

  41. Re:Predicted Predicted response by dmaxwell · · Score: 2, Interesting

    Kernel vulnerabilities are fairly rare. A new kernel is the only thing that mandates a complete system restart when upgraded. Linux and the BSDs got this right; it's the one overall thing I don't like about OS X. At most, OS X should only have to restart the GUI and close apps for most system patches....but nnnnooooo. Sheesh guys, you trumpet "the Power Of Unix"; use some of it.

  42. New boot system by Hard_Code · · Score: 2, Interesting

    The traditionaly Sys V init is archaic, crude, and disgusting. What, 6 hardcoded numeric runlevels? Wow, how useful is that. And I love ordering my startup scripts with two digit integers.

    *nix needs a major boot/shutdown system upgrade. I have migrated to minit, but that is primarily for low memory usage. It allows a rudimentary mechanism for specifying dependencies, but is geared mostly to be minimalistic. This 2003, I think we can come up with something better than Sys V init.

    Features of a next gen boot/shutdown service manager:

    * uses real dependency traversal on startup and shutdown (maybe using a small theorem prover like CML2, or maybe something like make)
    * allows configuration of arbitrary and unlimited sets of services, which can be named by arbitrary string literals - no longer chained to 7 numeric choices. e.g. "roaming laptop", "docked server", "minimal services", etc.
    * built-in service start/stop/restart/status/enable/disable tools, and standard service API with bindings for various languages (what, native services? imagine that...we do so for Windows NT+, e.g. apache) as well as Plain Old Shell Scripts. So every freakin' flavor/distro of *nix doesn't have its own fscking way to start/stop/enable/disable services.

    A lot of the garbage that goes on during startup (have you looked at the standard redhat scripts?) mounting drives and file systems, setting network and hardware parameters, etc., could probably use being standardized also, and either pulled into drivers or services or something, in a standardized fashion. Ideally all these APIs could be exposed both through command line tools, but also through desktop-integrated GUI tools, so that modifications don't entail digging up some ad hoc script on disk and modifying it and hoping you remember what the fuck you did a year ago in some system script.

    --

    It's 10 PM. Do you know if you're un-American?
  43. Re:Hmm by dfries · · Score: 2, Interesting
    For me it is in /etc/cron.daily/find
    rm it.

    If you can stand it, add "noatime" to /etc/fstab for your Linux partitions. You will always have 'new mail' mail instead of just 'mail', but if things are just reading from the drive, the drive can actually spin down instead of having to write just to say what it read.

  44. Amusingly, XP does this and more by drinkypoo · · Score: 2, Informative

    Windows XP is probably the current technology leader in terms of reducing boot time. Oh yes, I can hear you scoffing loudly already, but it's true! NT loads drivers in parallel, let alone services, though NT is bad about allocating memory, so having more memory makes it boot a lot faster. Believe it or not, my XP boot time was cut in half when I went from 512MB to 1GB of memory.

    XP also will defrag your disk automatically in such a way as to optimize boot. In other words, files accessed at every boot are placed together, so you don't have to do a lot of seeking at boot time. Now THAT is cool.

    I was just bitching about how annoyed I am with the state of windows, what a pile of crap code it must be. Someone told me that windows was great because it hardly crashed these days, and I was pointing out that having to reboot it weekly or more often does not constitute stability. So it doesn't crash... It just gets flaky enough to where you reboot it voluntarily. Woop de doo. I know many people don't have this problem, but they're probably not doing much customization or running very many apps for the most part, or they like to shut down at night.

    --
    "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
  45. Re:Predicted Predicted response by Pharmboy · · Score: 2, Informative

    as far as I know you don't have to reboot a linux machine to patch it. You can even reload a new kernel without patching it.

    If you are talking about a module, maybe, but not a completely new kernel version. Many (if not most) of us are using RH 'official' kernels instead of building our own now. Since most of the non-essentials are modules anyway, they are actually pretty efficient kernels. I do build my own kernels on VERY specific application servers, but really its just so I remember how to. Since this article is about cutting boot times, its not really relevant to servers anyway.

    Most of my servers spend more time POSTing than booting (Dell and IBM) so cutting the time in 1/2 that the init scripts loads will only save 10%-20% of the boot time. Not that important for a box I install a new kernel on, then schedule a reboot (not wise) or just get to work early and reboot first thing in the morning while the coffee brews. Not getting hits/traffic/use at 7am, and only have to do maybe twice a year, since not every kernel bug affects every server.

    --
    Tequila: It's not just for breakfast anymore!
  46. Use the Power Save features by billstewart · · Score: 3, Informative

    For the last N years, laptops have had a sleep/wakeup power-save feature. For the last N-2 years, it's generally worked well enough to be worth using all the time :-) Linux probably knows enough about power management for it to work on most laptops by now. Instead of shutting the machine down and rebooting it, you just close the lid and it saves its status and goes into some standby mode, and when you open the lid it wakes up again, where it left off, no need for reboot. On some machines, it also succeeds in doing this when the battery gets below X%.

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
    1. Re:Use the Power Save features by TopherC · · Score: 2, Informative

      I have to concur here. I've been running Linux on a Dell Inspiron 8200 for the past year, and have never gotten sleep or suspend-to-disk working. Evidently the NVidia driver doesn't support it when using AGP. I like AGP for things like, oh, say Neverwinter Nights...

      This is just one of many problems with suspending Linux. In fact, probably 3/4 of the people I know running Windows have at least one piece of hardware that crashes the computer if they try to use sleep mode. I guess suspend works for *some* people, but I doubt it works for a majority. So boot-up times are a big deal to me.

      I also want to add that I'd been kicking around in my head the idea of starting services in parallel for a long time now, but I never realized how nicely `make' solves the problem. I had imagined writing complex Perl scripts to do the work, and it's always a pain to work out whether or not forked processes have completed in Perl.

  47. Gentoo has service dependencies too by Kashif+Shaikh · · Score: 2, Informative

    Not trying to be a Gentoo evangelist, but a Gentoo rc script has specifiers for what a service depends on, so they can do away with static service level numbers.

    The dependency calculation is regenerated and cached, so bootup is faster. Now if someone could take gentoo service script as input and build a parallel service starter -- that would be a nice project.

    Btw, I have a Windows 2000 Server at work which I use for desktop use, and it takes *MUCH* longer to boot than a fully configured redhat 9 system. Why? Dunno, must be all the services and integrity checks that a "server" must have.

    Windows XP on the other hand takes about 30 seconds to boot.

    Kashif

  48. Re:boot? by dakryx · · Score: 2, Insightful

    Some people like to conserve energy when possible. Just do it! It's good for the environment!

  49. My own rc/init scripts by Skapare · · Score: 4, Interesting

    Back in 1999 I rewrote all the init scripts entirely from scratch. I did this after having spent a few years before hacking at init scripts in BSD/OS, OpenBSD, Redhat, Slackware, and Solaris. I experienced all the crankiness of these systems (Redhat and Solaris were the worst) and this time decided to avoid all that. I gave the scripts entirely different names so as not to conflict with existing scripts (was Slackware at this time). That way I could switch between them with just a change of /etc/inittab. It took a few hours, but I had a running fully functional system by the end of the day, and have been running on those scripts, as subsequently better debugged and tweaked, ever since. They booted up noticeably faster than even the Slackware scripts (which were about as fast as the OpenBSD scripts).

    Irontically, I didn't do this to get the boot speed. The init scripts are fast enough now that the kernel initialization time is longer, anyway. What I did this for was because I hated having a bunch of separate directories with symlinks in them for each run level. I didn't like having to use specialized tools to manipulate the system (I wanted to routinely use the tools I would have available if I were running from a rescue floppy trying to fix it). That meant doing things with a basic set of shell commands. Yet I didn't want to abandon having separate scripts for each service/daemon being started (or stopped as the case may be). What I ended up doing was creating a single subdirectory for all the individual service scripts, and making the script name have a pattern that included both the startup sequence (stop sequence simply ran backwards), as well as the run levels. Here's what the names in /etc/sys on my system look like:

    • 000.12345.net_lo
    • 020.--345.video_120x58
    • 040.--345.keymap
    • 060.-2345.mouse
    • 100.-2345.net_eth0
    • 101.-2345.net_eth1
    • 190.-2345.gw
    • 200.--345.random
    • 220.-2345.syslog
    • 240.--345.at
    • 260.--345.cron
    • 300.-2345.dns
    • 320.-2345.nsd
    • 400.-2345.ssh_main
    • 410.-2345.ssh_alt
    • 520.--345.inet
    • 540.-2345.ntp
    • 600.--345.mail
    • 620.--345.http
    • 640.--345.rsync
    • 660.-----.pop3
    • 700.----5.xfs
    • 780.--345.ftp
    • 800.--345.cache
    • 950.----5.xdm

    Figuring out which run level each service starts in is left as an exercise for the reader. BTW, I think most of the speed comes from the fact that I didn't add a lot of fat to my script system. That's easier to do when you do your own design.

    --
    now we need to go OSS in diesel cars
  50. Re:Predicted Predicted response by citog · · Score: 2, Interesting

    .. and it isn't the quickest to reboot either! Mind you, I don't find I'm rebooting that frequently compared to my Windows machine.

  51. Re:Shutdown? by aminorex · · Score: 2, Informative

    You can't unmount a filesystem until all of the
    processes that are using it are dead.

    Those processes may have vital data to write out
    before they exit, so shutdown gives them time
    to do so.

    Once all the processes that would usually be using
    the filesystems are dead, the filesystems are
    unmounted, and the system is halted.

    --
    -I like my women like I like my tea: green-
  52. Right but Wrong; be careful. by qortra · · Score: 2, Insightful

    Ok, I agree that boot time is important in many specific cases. However, you say

    I see... fanbody and girls... claiming that... b) linux boots very fast. They are wrong.

    This seems to be the prevailing wisdom here, so this is for everybody. I just have to disagree. A standard GNU/Linux distro (like Mandrake, for instance) will startup a buttload of services (depending on what you select at install time), and do far more than a standard Windows install (for instance). It will in fact run at startup every service that you've told it to install (again depending on if you tell it to, but I believe it will do this by default). Often this includes one or more databases (postgres, mysql), a web server (apache), perhaps a few file sharing services (samba, nfs, ftp), a few remote command services (ssh, telnet), and its usual collage of helpful newbie services (autodetect hardware, boot numlock, etc). Now, with all of this crap running on my antique P Pro 200-64mb, I boot in less than a minute from lilo to login prompt (and X is about 5 seconds more). I think XP home would barely beat that time on a system that old, and it can't serve things. And yes, faster systems scale nicely; my Debian system is extremely fast lilo->kdm; as good as my XP pro in fact, and it still has all the server trimmings.

    Now, on the other hand (for a fair comparison), if you've ever experienced a windows 2000 server machine with active directory, you know real pain. From boot.ini to load of video drivers is fast, but after that, restoring network connections can take as long as five minutes even on a fast system.

    So in conclusion, a default install of any random distro may or may not be slower starting up than another OS (read Windows), but just make sure you're making a fair comparison. If look through your /etc/rc3.d and find a whole bunch of services whose names you don't know, just remember that they might actually extend functionality beyond what you could get with another OS. If you ever truly do make your installation sleek and tiny, then give it another test and see what you find.

  53. RE:Gentoo parallel startup by Evilive · · Score: 3, Interesting

    I did it and noticed a decrease in the boot time, probably 15-20 sec. give or take. YMMV.

    --
    -- Two in the pink, one in the sink.
  54. Disk seeks are the real culprit? by dwidznz · · Score: 2, Interesting

    I've seen the exact opposite approach taken - switching from parallel to serial to reduce startup times.

    The reason this worked was that starting processes in parallel increased disk contention and the extra seeks brought the machine to a crawl.

    Sure, that was on a system with very slow seek times, and not much in the way of disk caching and scheduling (an Amiga 500 with no HD). A lot of things have improved since then, but seeks are still extremely slow in machine terms, and we also have virtual memory and demand page loading which I imagine don't help the problem.

    Maybe keeping data needed at startup centralised on the disk (e.g. in the boot partition) would help.

    As disk accesses during startup are probably pretty predictable (consistent from one boot to the next), it may be possible to pre-load the disk cache to improve startup times.

    A simple approach would be to log disk blocks accessed during startup, and then read them (in a sensible order of course, and in parallel across disks) at the start of the next boot.

  55. LinuxBIOS by Taco+Cowboy · · Score: 2, Interesting



    I thought there is an outfit called "linuxbios" that supposed to make re-booting, especially cold-booting a very fast process.

    Can anyone here tell me the recent progress of "linuxbios" ?

    Thank you !

    --
    Muchas Gracias, Señor Edward Snowden !