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.
Just turn off services you don't need (Score:5, Informative)
Other things to speed up boot time (Score:5, Informative)
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.
Does it really take that long? (Score:3, Informative)
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)
FastBoot.org? (Score:2, Informative)
http://www.fastboot.org/
Spooky (Score:2, Informative)
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).
Re: "you only need to boot it up once" (Score:5, Informative)
Re:Timely (Score:1, Informative)
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)
http://www.netbsd.org/guide/en/chap-rc
Additionally, there's an article here. http://www.daemonnews.org/200108/rcdsystem.html
Gentoo can do that too (Score:2, Informative)
RC_PARALLEL_STARTUP="yes"
Re:This is actually important (Score:5, Informative)
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.
Apple did this in Jaguar (Score:5, 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:
Re:Make? (Score:3, Informative)
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?".
Re:Another way to speed up booting Linux (Score:3, Informative)
Been there, done that (Score:4, 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.
Nostalgy (Score:4, Informative)
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)
Still, looks nifty.
Re:This is actually important (Score:2, Informative)
QNX has had this for years (Score:1, Informative)
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.
That's exactly what I wrote minit for (Score:5, Informative)
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)
I've been doing it since 1999. (Score:5, Informative)
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,
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)
> 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.
Richard Gooch's method (Score:3, Informative)
Re:PowerPC Linux users had compiled boot 'scripts' (Score:3, Informative)
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).
Re:Predicted response (Score:5, Informative)
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 : )
Re:Apple did this in Jaguar (Score:3, Informative)
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.
Amusingly, XP does this and more (Score:3, 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.
Re:Isn't there a way (Score:3, Informative)
Re:PowerPC Linux users had compiled boot 'scripts' (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 [gentoo.org] is Gentoo's own explanation..
Pretty swanky really, and very easy to use.
Re:Predicted Predicted response (Score:3, Informative)
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)
Re:Make? (Score:4, Informative)
So in MakefileRC5, "include
I think that might actually work!
Use the Power Save features (Score:4, Informative)
Gentoo has service dependencies too (Score:3, Informative)
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)
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.
Re:Other things to speed up boot time (Score:2, Informative)
www.linuxbios.org
current record: 3 seconds!
--Blerik
Re:Make? - try opensource.openfuel.com/frc (Score:1, Informative)
this purpose: FRC, its homepage is opensource.openfuel.com/frc
Re:This is actually important (Score:3, Informative)
Re:Use the Power Save features (Score:3, Informative)
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.