Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
IBM Software Linux

Booting Linux Faster 625

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.
This discussion has been archived. No new comments can be posted.

Booting Linux Faster

Comments Filter:
  • by Anonymous Crowhead ( 577505 ) on Thursday September 18, 2003 @06:55PM (#6998889)
    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.
  • by epiphani ( 254981 ) <epiphani@daYEATSl.net minus poet> on Thursday September 18, 2003 @06:56PM (#6998894)
    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.
  • by pclminion ( 145572 ) on Thursday September 18, 2003 @07:00PM (#6998937)
    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? ;-)

  • Serel (Score:5, Informative)

    by ensignyu ( 417022 ) on Thursday September 18, 2003 @07:04PM (#6998979)
    Serel [fastboot.org] 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.
  • FastBoot.org? (Score:2, Informative)

    by nickread ( 217474 ) on Thursday September 18, 2003 @07:08PM (#6999011) Homepage
    Isn't this basically the same thing (different implementation though).

    http://www.fastboot.org/
  • Spooky (Score:2, Informative)

    by JayJayEm ( 220851 ) on Thursday September 18, 2003 @07:11PM (#6999036)
    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 [microsoft.com]

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

  • by vlad_petric ( 94134 ) on Thursday September 18, 2003 @07:13PM (#6999047) Homepage
    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
  • Re:Timely (Score:1, Informative)

    by fpu ( 96469 ) on Thursday September 18, 2003 @07:24PM (#6999146) Homepage
    ...which is exactly what Windows XP does, and why it boots up so much faster than previous Windows. Network services (which could depend on a slow network connection/DHCP server) start up after the initial login screen is shown.

    In Windows 2000 times, you had to wait for the network interfaces to come up before you could login -- there was even a dialog that showed something like "Bringing up network interfaces" or something like before the "Press Ctrl-Alt-Del to logon" would show up.
  • netbsd rc.d (Score:5, Informative)

    by Fritz_the_Cat ( 100676 ) on Thursday September 18, 2003 @07:25PM (#6999151)
    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
  • by Anonymous Coward on Thursday September 18, 2003 @07:29PM (#6999176)
    Gentoo can do that too, just edit /etc/conf.d/rc:

    RC_PARALLEL_STARTUP="yes"
  • by John Hurliman ( 152784 ) on Thursday September 18, 2003 @07:30PM (#6999184) Homepage
    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.
  • by tim1724 ( 28482 ) * on Thursday September 18, 2003 @07:36PM (#6999219) Homepage Journal

    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:

  • Re:Make? (Score:3, Informative)

    by The Pim ( 140414 ) on Thursday September 18, 2003 @07:39PM (#6999241)
    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 [tip.net.au] 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?".

  • by sfraggle ( 212671 ) on Thursday September 18, 2003 @07:47PM (#6999286) Homepage
    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.
  • by CausticWindow ( 632215 ) on Thursday September 18, 2003 @07:52PM (#6999329)

    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.

  • Nostalgy (Score:4, Informative)

    by Peaker ( 72084 ) <gnupeaker@NosPAM.yahoo.com> on Thursday September 18, 2003 @07:54PM (#6999341) Homepage
    I have started a discussion [debian.org] 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 :)
  • Re:Serel (Score:4, Informative)

    by gmhowell ( 26755 ) <gmhowell@gmail.com> on Thursday September 18, 2003 @07:57PM (#6999357) Homepage Journal
    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.
  • by nivedita ( 179357 ) on Thursday September 18, 2003 @08:02PM (#6999412)
    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.
  • by Anonymous Coward on Thursday September 18, 2003 @08:03PM (#6999436)
    QNX does this more or less automatically. Under QNX, drivers and file systems are just programs. All the kernel does is pass messages around. As programs start up and take over sections of the pathname space, creating what look like directories in /dev, /fs, and so forth, other programs can start using those services.

    So all a program has to do is to wait for the pathname it needs to appear. There's a "waitfor" command in boot scripts for this, or programs can just wait for the pathname to come up, then go.

    There's an enormous architectural advantage to having unified interprocess communication as a primitive, rather than an afterthought.

  • by Fefe ( 6964 ) on Thursday September 18, 2003 @08:05PM (#6999450) Homepage
    See www.fefe.de/minit/ [www.fefe.de] 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).
  • Re:Hmm (Score:1, Informative)

    by Anonymous Coward on Thursday September 18, 2003 @08:08PM (#6999485)
    Perhaps you should suspend to disk [sourceforge.net] rather than shutting down.
  • by pr0ntab ( 632466 ) <pr0ntab@g3.1415926mail.com minus pi> on Thursday September 18, 2003 @08:10PM (#6999495) Journal
    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.
  • Linux DID adopt it. (Score:3, Informative)

    by Balinares ( 316703 ) on Thursday September 18, 2003 @08:43PM (#6999789)
    > 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.
  • by ldamerow ( 708805 ) on Thursday September 18, 2003 @08:43PM (#6999802)
    Richard Gooch published an interesting implementation of parallel init scripts almost a year ago: http://www.atnf.csiro.au/people/rgooch/linux/boot- scripts [csiro.au]
  • 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).

  • by AstroDrabb ( 534369 ) on Thursday September 18, 2003 @09:01PM (#6999931)
    This isn't true. I am one of the moderators for Red Hat @ yahoo [yahoo.com] and I am very active in Linux @ Yahoo [yahoo.com]. 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 : )
  • by nvrrobx ( 71970 ) on Thursday September 18, 2003 @09:11PM (#7000003) Homepage
    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.
  • by drinkypoo ( 153816 ) <drink@hyperlogos.org> on Thursday September 18, 2003 @09:23PM (#7000092) Homepage Journal

    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.

  • Re:Isn't there a way (Score:3, Informative)

    by irc.goatse.cx troll ( 593289 ) on Thursday September 18, 2003 @09:23PM (#7000093) Journal
    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.
  • by LocoBurger ( 18797 ) * on Thursday September 18, 2003 @10:02PM (#7000385) Homepage

    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 [gentoo.org] is Gentoo's own explanation..

    Pretty swanky really, and very easy to use.

  • by Pharmboy ( 216950 ) on Thursday September 18, 2003 @10:19PM (#7000468) Journal
    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.
  • Re:Make? (Score:2, Informative)

    by cjj2 ( 708814 ) on Thursday September 18, 2003 @10:35PM (#7000554)
    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.
  • Re:Make? (Score:4, Informative)

    by Webmonger ( 24302 ) on Thursday September 18, 2003 @10:41PM (#7000584) Homepage
    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!
  • by billstewart ( 78916 ) on Thursday September 18, 2003 @10:50PM (#7000620) Journal
    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%.
  • by Kashif Shaikh ( 575991 ) on Thursday September 18, 2003 @10:57PM (#7000662)
    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
  • Re:Shutdown? (Score:3, Informative)

    by aminorex ( 141494 ) on Friday September 19, 2003 @01:16AM (#7001343) Homepage Journal
    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.
  • by ysachlandil ( 220615 ) on Friday September 19, 2003 @07:25AM (#7002408)
    Flashing linux into BIOS:

    www.linuxbios.org

    current record: 3 seconds!

    --Blerik
  • by Anonymous Coward on Friday September 19, 2003 @07:52AM (#7002495)
    Instead of using make use a utility which has been designed for
    this purpose: FRC, its homepage is opensource.openfuel.com/frc
  • by mgkimsal2 ( 200677 ) on Friday September 19, 2003 @09:37AM (#7003146) Homepage
    It doesn't work with most laptops, that's why not.
  • by TopherC ( 412335 ) on Friday September 19, 2003 @11:07AM (#7004118)
    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.

To the systems programmer, users and applications serve only to provide a test load.

Working...