LWN.net Logo

Innovators get Linux to boot in 1 second (EDN)

EDN reports that MontaVista Software has developed an embedded version of Linux that boots in less than a second. "In addition to designing real-time Linux, MontaVista has been working on the development of real-fast Linux, a Linux operating system that boots in less than 1 second. The team who worked on the project includes Alexander Kaliadin, Nikita Youshchenko, and Cedric Hombourger. Many on the team also worked on the MontaVista real-time Linux. "One of the first things we did years ago was to make the Linux scheduler pre-emptive and deterministic," says Hombourger. These fast-boot developments are not necessarily limited to real-time or an embedded Linux; however, they can get a conventional Linux distribution to boot in 1 second, as well."
(Log in to post comments)

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 6, 2010 0:32 UTC (Sat) by BrucePerens (guest, #2510) [Link]

Every few months another company crows about getting Linux to boot very quickly. Or we see a story about the same company doing it, again. IMO it's not a big deal. Certainly nothing to make you an "innovator".

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 6, 2010 1:12 UTC (Sat) by bronson (subscriber, #4806) [Link]

Amen to that. This is just a bunch of hard-coded hacks (no way they'll ever
go back upstream) trying to get some press attention. Not interesting.

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 6, 2010 2:54 UTC (Sat) by BrucePerens (guest, #2510) [Link]

How, then, could we "do it right" in a way that could go upstream?

Perhaps provide a way for the kernel to create a device list and consume that list on subsequent boots? And a way to set device polling delays?

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 6, 2010 18:37 UTC (Sat) by yoush (subscriber, #38940) [Link]

Particular configuration that boots within 1 or 2 secs can't be "mainlined" - it has no interest outside of particular project. Yes it sometimes contains ugly hacks - although we work hard to avoid that whenever possible.

What can and should be mainlined is infrastructure work that was done. I'm the engineer who designed and wrote it, and I believe it is clean enough to be mainlined, perhaps after several review/fix iterations.

Then, this infrastructure may be used to accelerate boot of new systems.

If this code will be submitted or not, depends on non-technical decisions within Montavista.

Anyway, this is not about generic desktop or server usage. It is still for embedded systems, running not-too-complex userspace.

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 6, 2010 17:34 UTC (Sat) by marcH (subscriber, #57642) [Link]

I cannot believe hard-coded hacks are enough to accelerate boot (or anything else) by two orders of magnitude. There must be some interesting ideas to steal from this experiment.

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 6, 2010 18:23 UTC (Sat) by BrucePerens (guest, #2510) [Link]

It's simple to get Linux to boot in one second.

First, cut out all of the drivers that your particular hardware configuration doesn't use. Then, you don't have to wait for them to poll for their device and fail.

Second, configure all of the drivers that you still have to only initialize the devices that are present in your hardware configuration. So, you poll for one disk controller rather than the eight that the driver would look for by default (for example). Then, if there are any remaining waits in drivers that don't know exactly what hardware will answer, remove them.

As you can see, we're talking about a dirty hack here. Not innovation. The key is that the kernel has "booted" when you first see it printing. The rest of the time is device configuration.

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 7, 2010 0:46 UTC (Sun) by marcH (subscriber, #57642) [Link]

If it's so easy, then why do I have to do it myself? It's not like my hardware configuration is changing every day.

Don't get me wrong: here I am not complaining about missing feature(s). But about dismissing mere ideas.

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 7, 2010 1:49 UTC (Sun) by BrucePerens (guest, #2510) [Link]

Back in the days of Linux 0.99, most of us built kernels that were tuned for our specific PC hardware. This was because our PCs had 4 MB RAM total, if we were lucky, and we wanted to get the most out of that RAM. These kernels booted more quickly than the generic ones.

These days, the vast majority of people use kernels that are configured for a generic device set, even if they build them by themselves. Most people, however, use a kernel produced by their distribution and meant to work with a very wide set of devices, literally anything a customer could be expected to use.

The price of this is that you wait a bit longer for devices to configure. The reason it's left that way is that the vast majority of users don't care enough to custom-configure their systems and get the ultimate in booting speed.

Now, the part that could be made faster for everyone is the part after the kernel is finished and all of the user-mode stuff is coming up. Using one of the various init replacements like upstart, runit or launchd will do that for you. Most distributions are moving in this direction, but not very quickly, because their users don't have this feature high on their priorities. This doesn't matter much for embedded systems, because they generally don't start very many processes at boot time.

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 7, 2010 16:15 UTC (Sun) by bronson (subscriber, #4806) [Link]

Ah, I remember those days... Getting out the flashlight to try to read the numbers on the tiny chip hidden behind a cap farm. Rebuilding kernel after kernel after kernel just trying to get a combo that will bring up working VGA, disk, serial AND networking without randomly locking up. Rebooting your kernel over and over with different ISA addresses praying one will work (then, if it does, praying that it doesn't change).

But that's exactly the effort that's required to drastically reduce your boot times. Specifically:

Your kernel starts using hardware before probing for it. If the hardware is not there or is mapped to a different area (did you remove that unused second NIC?), pray that the computer just hangs instead of writing random garbage on your hard disk.

The drivers must use the state of each device as the BIOS/boot loader left it, no matter how horribly broken. It generally takes a second or two for everything to settle after resetting it.

Now, once your computer boots, DONT TOUCH IT! If you insert a parallel card, it's time to start compiling kernels again! There goes another night trying to figure out the magic combo of config settings and boot params to get everything working.

And, for pity's sake, don't try to boot your kernel on another machine. If your motherboard fries, you can't just swap it out for another one, or plug your hard disk into another computer. It wouldn't work. You get to start over from scratch.

Those days were brittle. I have no desire to go back, even for a 0 second boot time. I love being able to swap hardware and disks without having to analyze everything first!

Of course, none of this matters in the embedded environment described in the article. A super custom kernel isn't much of a drawback if everything is soldered down and you have full control over the BIOS. For regular computer hardware, though, fast boots tend to come with huge drawbacks.

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 8, 2010 4:23 UTC (Mon) by iabervon (subscriber, #722) [Link]

You don't actually have to examine the chips by hand; you can have your first kernel probe everything and figure out the hardware, and look at lspci and sysfs to figure out what drivers and such you're actually using. Then you can build a second kernel that only works for that hardware. Every once in a while, someone does a bit of work on something to configure the kernel for the system you're running the configuration toll on, but the kernel configuration isn't really organized for that, and there aren't the necessary options to get the extreme speedups (like putting the PCI bus information in the kernel instead of asking the hardware at boot time).

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 8, 2010 9:13 UTC (Mon) by michaeljt (subscriber, #39183) [Link]

I think that the thread is still talking about Linux 0.99, which didn't have lspci and sysfs. My
first Linux system (which was an advanced 1.2.13) was running on a 486DX4 with VESA local
bus, so lspci wouldn't even have helped :)

About optimising for a particular configuration - I do think that it would make sense to be able
to provide a generic kernel with an "expected configuration" at boot time, so that it initially
only probes for that hardware. If it finds all the hardware in that configuration, and can boot
using it, it could put off any probing for additional hardware until after boot properly speaking,
when the probing can run in parallel with other things. Otherwise it does a full probe during
boot. That would badly slow down recognition of configuration changes of course, but it
should speed up the general case rather effectively.

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 8, 2010 10:26 UTC (Mon) by marcH (subscriber, #57642) [Link]

> Those days were brittle. I have no desire to go back, even for a 0 second boot time. I love being able to swap hardware and disks without having to analyze everything first!

Why limit yourself? You can have both a 0 second boot time AND the ability to swap hardware. Just keep two kernels installed: the generic one provided by your distribution and the one tailored to your current configuration.

A great new technique does not always require you to drop everything that was done before. I use a car, a mobile phone and read news on the internet. Yet I do not feel like I am "going back" when I am walking, using my landline or reading a paper.

Back to the interesting question: is it possible to automate the build of a no-crap, fast boot kernel tailored to my PC? I guess this could borrow a few tricks from mkinitrd/dracut.

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 11, 2010 10:08 UTC (Thu) by berndp (guest, #52035) [Link]

IMHO the (main) problem is: where could you store the last known configuration so that it can be processed by the (initially booting) kernel.
Obviously you can't store the type and data of the boot harddisk and root filesystem in a file on the root filesystem. Is a block left in the MBR or where the boot loader comes from?

The first simple solution is: on the kernel commandline. But do you want to some script to mess with the kernel's commandline? And how does one keep them from changing selected commandlines - namely those that I edited by hand (for whatever reason and for whatever kernel - self-compiled or distribution-installed, copied or not).
The second is: (re)generate an appropriate initramfs/initrd (but that won't work for non-initramfs/initrd systems ....).

Other than that: TTBOMK no even somewhat generic storage exists in the "normal PC world" where such information could be stored. In the embedded world with their quite controlled environment including NAND/NOR-flashes (and usually not historically loaded!), this is much easier. And many of tehm allow for a complete remote firmware replacment means (which usually means that you also have some extra storage for device-specific data which *must* survive all firmware upgrades).

Next question: Assume I buy some disk and plug into the PC. How does the kernel find it?
You have a (boot-time or not) script which looks for that and asks the users (which and how? The first that logs on?). And do the drivers support that?

Not that that is all that impossible - it's just (IMHO) a lot of tedious (and not overly appealing) work and outside the kernel (read: it - also - depends on the distribution and some of their "boot environment").

So it's (IMHO) probably easier to help the suspend-to-disk folks to get that stable and into mainline and into the distributions so that people use it for the daily "going home ritual" (if they actually do more than just start the screensaver - similar to me). And leave warm/cold starts for "we rescan the whole machine" as it is.

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 7, 2010 21:41 UTC (Sun) by dwmw2 (subscriber, #2063) [Link]

"First, cut out all of the drivers that your particular hardware configuration doesn't use. Then, you don't have to wait for them to poll for their device and fail.

"Second, configure all of the drivers that you still have to only initialize the devices that are present in your hardware configuration. So, you poll for one disk controller rather than the eight that the driver would look for by default (for example). Then, if there are any remaining waits in drivers that don't know exactly what hardware will answer, remove them."

Erm, that may have been a sensible suggestion when we were probing for 17 different types of ISA sound cards each at 5 potential addresses, but these days we enumerate hardware properly — even on embedded systems, through the device-tree etc.

Many of the delays we have left are for crap hardware which needs a certain amount of time to reset... and the solution there is often not to reset it. When you have a decent firmware which you can trust to put devices in the correct state before the kernel boots, that can work quite nicely — even video modesetting can be inherited by the kernel without having to set it up again.

Another approach is to do it all in parallel, so that you're waiting for all the crap devices at the same time rather than resetting them one at a time. That work is going into the upstream kernel.

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 8, 2010 1:02 UTC (Mon) by estate66 (guest, #64154) [Link]

very goog,little time

Fixed hardware configuration still isn't enough

Posted Mar 8, 2010 12:08 UTC (Mon) by epa (subscriber, #39769) [Link]

I sometimes use an iMac G5 running Mac OS X 10.4. This is a textbook example of a fixed and tightly controlled hardware specification - the only internal upgrade a user can perform is to install more RAM. The operating system and hardware are controlled by the same vendor, who has a reputation for giving attention to user-visible 'polish', which would include boot times. And yet despite all this, the machine still makes you wait for about a minute when you switch it on before you can use it. There must be more to starting a system than merely finding and initializing the hardware.

(I still remember my old Archimedes, which had the operating system in ROM and started up instantly. But this was a fairly primitive system written in assembler.)

Fixed hardware configuration still isn't enough

Posted Mar 8, 2010 14:41 UTC (Mon) by dmaxwell (guest, #14010) [Link]

The hardware is fixed and tightly controlled but OS X is generic to the extent that Apple hardware varies. Macs can and do differ on exactly which chipset, video, network, and audio hardware they are running. Apple DOES have the advantage that the ways in which this can happen are limited and known in detail. It is even possible for a correctly constructed OS X image to boot either PowerPC or Intel hardware.

And OS X takes some advantage of some hardware profiling. The very first boot of a freshly imaged Mac will take a bit longer and one reason why is the drivers needed are determined and the machine uses a cache of these for subsequent starts.

Fixed hardware configuration still isn't enough

Posted Mar 8, 2010 17:30 UTC (Mon) by paulj (subscriber, #341) [Link]

Does no one else remember how on older Unix systems you could relink your
kernel, so as to tailor it for your systems? No source involved, just a tree
of binary object files, and if you installed new hardware or if you wanted
to leave out drivers for things you didn't have you ran a command that took
no more than a few minutes.

IRIX 6 had this, more than a decade ago.

Fixed hardware configuration still isn't enough

Posted Mar 9, 2010 5:09 UTC (Tue) by quotemstr (subscriber, #45331) [Link]

Hrm, thanks for that. Having never used an old-style proprietary Unix, I wasn't aware that they were customizable to that degree.

Fixed hardware configuration still isn't enough

Posted Mar 11, 2010 18:02 UTC (Thu) by anton (guest, #25547) [Link]

Customizable is a nice spin on that. IIRC on Ultrix (or was it Digital Unix?) we had to "recompile" the kernel if we wanted to change the IP.

Fixed hardware configuration still isn't enough

Posted Mar 16, 2010 13:28 UTC (Tue) by jeremiah (subscriber, #1221) [Link]

I don't quite remember it being that bad. Although there were a number of PITA points with it.

Fixed hardware configuration still isn't enough

Posted Mar 10, 2010 11:57 UTC (Wed) by epa (subscriber, #39769) [Link]

Since Linux drivers are usually built as loadable modules, isn't that essentially what we have? The relinking for your hardware is done at run time.

Fixed hardware configuration still isn't enough

Posted Mar 10, 2010 15:10 UTC (Wed) by paulj (subscriber, #341) [Link]

Yes true - forgot completely about modules cause of people talking about
recompiling kernels. :) The bit that isn't there, possibly, is leaving out
drivers that are not needed. Though things like mkinitrd already do that too
to some degree.

Innovators get Linux to boot in 1 second (EDN)

Posted Mar 15, 2010 14:05 UTC (Mon) by MTecknology (subscriber, #57596) [Link]

Boot time matters to a lot of us. In my case, my battery doesn't live long enough to even use suspend anymore. At my boot times it doesn't even pay to use hibernate anymore.

I have about a 12sec boot with my trimmed down Ubuntu installation and a customized kernel.

When it comes to saying that it will never matter because it won't make it to mainline I have to disagree. At some point everything starts out in somebodies imagination. The first attempts to finish it are usually ugly hacks and eventually tidied up to the point where everyone else can use them.

Personally, seeing a 1sec boot is impressive. What will be more impressive is when I an see a detailed list of everything they did so I can try to reproduce it myself. I don't expect to ever reach 1sec boot but in my next system (laptop) I do want to reach a 5sec boot. We'll see how that goes.

Copyright © 2010, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds