Full translation of the article, announced in
http://habrahabr.ru/blogs/linux/41701/At the Plumbers Linux Conference (Linux Plumbers Conference), Arjan van de Ven, developer of Linux solutions from Intel, the author of PowerTOP, and Auke Kok, developer of the Intel Open Source Technology Center, demonstrated a Linux-based system that boots only 5 seconds The hardware basis for this system was the Asus EEE PC, with an SSD drive. The developers overcame the “load in 5 seconds” line in two versions: a modified Fedora and a modified Moblin. EEE PC loaded faster than the projector had time to recognize the signal from the video output of the device, so they had to do without it and simply bring the laptop closer to the audience.
How did they do it? Arjan said that it all started with the correct formulation of the problem: “Making the system not 'load faster', but make it 'load in five seconds.'” Instead of saving a second here, a second there, a time limit was set for the entire boot process Each download step must be done within this time frame. And no fraud: “Completing the load means stopping disk access and CPU load,” said Arjan. The time is not measured until the desktop is loaded, while services continue to load in the background (although some companies measure the load time of their OS exactly up to this point). Boot time does not include turning on the network, but includes starting NetworkManager. A system with a traditional hard drive loads longer, but Arjan said that he ran the system on a ThinkPad - and it booted in less than 10 seconds
On this hardware, Fedora boots in 45 seconds — from powering on to the password entry screen. Bootchart, a tool created by Ziga Mahkovec, reveals the details of the download. On the Fedora boot graph (Figure 1), it can be seen that during the boot process there are some time devouring moments. It uses a full second to start loopback interfaces — to check whether all network interfaces are loopback interfaces. 2 seconds are required to start sendmail. “Everyone pays for everything, despite the fact that not everyone needs sendmail,” said Arjan, and suggested that for home use -SMTP only for outgoing mail — ssmtp can be used.

Fig. one')
Another costly process in Fedora is “setroubleshootd”, a useful tool for troubleshooting Security Enhanced Linux (SELinux) settings, it takes a full five seconds. There is no reason to blame Fedora - some independent projects use an incomprehensible amount of time / resources to work. The X Window System runs its own C preprocessor and compiler when it is loaded, just to compose its own keyboard charts (keyboard mappings).

Fig. 2Ubuntu boot is almost the same - 2 seconds faster (Figure 2). It spends 12 seconds on modprobe, just to load a single module. The proprietary driver download tool uses 2.5 seconds - on a system that does not need proprietary drivers. “Everyone pays for the ability to use closed drivers,” said Arjan. And finally, GDM Ubuntu takes 2.5 seconds of pure CPU time, just to display a background image.
Both distros use splash screens. Both Arjan and Auke agreed: “We hate splashing screens. In the time it takes to see them, we want everything to be done. ” The time that the developers of the distribution kit spend on splashing screens is much more than the Intel team spent in order to load in such a time that splashing the screen is simply not needed.
How they did it: CoreThe first step is the plan. One second to load the kernel with all modules. “Early boot”, including boot scripts and background jobs — another one second. X Server - another one second, and 2 seconds for the workbench programs.
The kernel was rebuilt without an initrd, which requires half a second “for nothing”. All modules that are needed are embedded in the kernel. Arjan said: “There is a set of modules that will cover the needs of 95% of laptops.” He suggested that you just need to make a separate distribution with the kernel using the initrd for the remaining 5%.
Some work on the kernel allows parallel loading of some subsystems. For example, the modified kernel launches the Advanced Host Controller Interface (AHCI) initialization to manage storage at the same time as the Universal Host Controller Interface (UHCI) to control USB (Fig. 3). “Probably, we could reduce the time to half a second, but, bringing the time to a second, we stopped,” said Arjan. The kernel load time should be reduced to half a second to release 2.6.28, thanks to a new patch of the AHCI support module written by him.

Fig. 3Another change to the kernel was a small patch to support readahead. Kernel Terere keeps track of what information needs to be read at boot time, to make it immediately accessible in user space (userspace) at the end of its boot. All this together makes it possible to use readahead, which is part of the early boot.
How they did it: readahead and init
Fedora uses Upstart as a replacement for “init”, the first program launched in user space. But the Intel team returned to the original init. The order of tasks that init performs has been changed so that you can do 3 things at the same time: first, the “sReadAhead” process for reading data from the disk and caching it in RAM, then the critical moment - checking the file system, then D-Bus system interprocess communication, then X-graphics subsystem, then desktop. Well, and the third set of programs to run the Hardware Abstraction Layer (HAL), then udev - the device manager of the "hot plug", then the network. Udev is only used to support devices that can be connected later - the system uses the traditional / dev folder, so the boot does not depend on udev.
Organizing tasks helps to more efficiently use the processor. For example, X pauses for half a second waiting for information about supported video modes. This time uses the HAL for its download (Figure 4)

Fig. fourIn the graph of disk use and processor, both are used to the maximum almost all the boot time: thanks sReadAhead. When X starts, it does not need time to read from the disk, since all data is already in the RAM cache. sReadAhead is based on Fedora's Readahead, but it is modified to take advantage of the list of data to be read from the kernel. sReadAhead should already be published on moblin.org, and the kernel patch will be posted as soon as Arjan makes it together with Ted Ts'o (an ext3 file system developer) - during the meeting Ted made some suggestions on how to reorganize the blocks on the disk so that increase the speed even more.
In this project, there is one hard limitation: 75 megabytes for reading from disk - 3 seconds of information transfer at a speed of 25 MB / s - the limitation of SSD drives. “Thus, we were forced not to read the files entirely. We only read pieces of files that we actually use, ”said Arjan. sReadAhead uses only idle time of the disk subsystem, so if something else requires disk access, it gets it. Without using readahead, the system boots in 7 seconds, with its use - we get our goal - download in five seconds!
X is still a problem. “We needed to do a lot of X damage,” said Arjan. Part of the work was aimed at preventing the C compiler from running by reusing character tables, but the rest of the work was more temporary. The current development direction of X is aimed at moving most of the hardware definition and configuration into the kernel, which should reduce the overall boot time. As long as some of the core time is already being used to determine the hardware, this time can be used to initialize more devices at the same time - this is a more efficient use of time, initializing the video card at the same time as USB and ATA. Developer X Keith Packard (also an Intel employee) offered his help. As a result, the video mode is installed by the kernel during the initialization of the rest of the equipment (Fig. 3). The presented fast-booting system does not use GDM (password entry screen), it is loaded directly into the user session, with the XFCE environment. Arjan suggested, instead of GDM, to load the session of the last user, but to load along with a screensaver that blocks the use of the system without entering a password. If another user wants to log in, he must use the “Switch User” screensaver button.
In conclusion, Arjan said: “Do not stop at 'make the download faster'.” This is an incorrect formulation of the problem. The correct task is to make the download fast. And do not make all users wait because someone needs some kind of module or sendmail on their laptop. Make sure that users only pay for what they actually use. Distribution developers should not do separate initrd and non-initrd distributions, "he said later:" The kernel should try to boot without an initrd, and use it only if it cannot see / sbin / init (as might happen if there is no module to mount root file system.)
PowerTOP caused a flurry of changes to save energy in all areas of Linux software.

Fig. fiveThe conference ended on Friday (the report was on Tuesday), and conference chairman Kyle McMartin reported that Fedora and Ubuntu had corrected some unreasonable delays in their download process, which caused a storm of applause and approvals.