Arjan Van de Ven and Auke Kok the two Linux developer at Intel’s open Source Center had demonstrated booting Linux system in five seconds. They demonstrated at Asus EEE PC that had a solid state storage both developers beaten the 5 seconds time by loading 2 soft wares Fedora and Moblin. They demonstrated that in front of audience.
Now question is that how they did that? According to Arjan it starts with right attitude, that doesn’t mean booting faster, its only about booting in 5 seconds. Its better to set a time budget for whole system rather than saving seconds here and there and every step of the boot should have to be complete in allocated time.
Nothing can be skipped while booting because Booting means making CPU and disk idle. That 5 second booting time did not include bringing up the network but that includes starting Network Manager. Arjan said that a conventional hard disk in a system take more time for start up, he has run the same load on a ThinkPad which taken 10 second time.
Fedora takes 45 seconds from power on to GNOME Display Manager log in screen. Boot Chart tool gives some details about that. In Boot chart figure 1 of Fedora boot, that figure shows the system is doing some time wasting things. It takes a whole 1-second in starting and checking the loopback device to see if all the network interfaces on the system are loopback. Then 2 seconds to start “send mail”. For that Arjan suggested for the common laptop use case that user can simply run ssmtp server instead of SMTP server, which is used only for outgoing mail.
There was another time consuming process of Fedora that’s setroubleshooted, which is a useful tool for finding problems with Security Enhanced Linux configuration. That took 5 seconds. Fedora can’t be blamed for everything there is some other upstream project, which makes delay also. In order to build keyboard mappings the X Window System runs the C preprocessor and compiler on startup
In figure 2 it’s shown Ubuntu’s boot is almost same also just two seconds short. It taken 12 seconds running modprobe running a shell running modprobe, which ended up loading a single module. The tool for adding license-restricted drivers takes 2.5 seconds on system and to display the background image Ubuntu’s GDM takes more 2.5 seconds of CPU time.
Both distributions shows splash screens. Arjan and Auke agreed that they hate splash screens. Because they want it done before you see it. The Intel team’s booting time was less than the development time that distributions spend on splash screen.
How they did it: the kernel
In step one the kernel started in 1 second including all modules. Background tasks and init scripts started in another second. In 3rd second X started and next two seconds desktop environments taken.
In half second kernel have to be built without initrd. Same like that all module required for boot must be built into kernel. Arjan said that with a handful of modules you cover 95% of laptops out there he also suggested building initrd based image to cover the remaining 5%.
Some subsystems asynchronous initialization is made possible by some kernel work. As to handle the storage the modified kernel starts the Advanced Host Controller Interface initialization in the same time the Universal Host Controller Interface handle’s USB (fig.3). Arjan said that we can boo the kernel probably in half second but we got it down to a second and we stopped. Thanks to brand new fix in the AHCI support, which made kernel down to a half second by 2.6.28.
There was a one more kernel change that a small patch to support read ahead. The kernel keeps track of that blocks it had to read at boot after that delivers that information to userspace when the booting is complete that enables readahead which is part of early boot process.
How they did it: readahead and init
The first userspace program is init traditionally, while Fedora uses Upstart for replacement of init. But Intel team used the original init. The task’s order handled by init is modified to do three things at same time. First there is a sReadahead process which read blocks from disk that are cached in memory. Second is critical path in which filesystem is checked, the D-Bus inter-process communication system, then X, then the desktop. Third step is set of programs to start Hardware Abstraction Layer (HAL), udev manager for hot plugged devices and then networking. To make not depended boot on udev the system haves a persistent dev directory, udev basically is used only to support the devices, which are added later in system.
To enhance the efficiency of the CPU the arrangement of tasks helps a lot. For instance in Fig.4. X delays for about half a second for video modes ad that’s when HAL does its CPU-intensive startup.
Thanks to sReadahead, as the graph shows usage of CPU and disk both are at maximum for most of boot time. Everything which it needs while staring X is already in cache so it wont have to wait to read from disk. Though sReadahead is based on Fedora Readahead but its modified to take advantage of the kernel’s new list of blocks read.
As there is a hard limit of 75MB of reads in order to boot set by the maximum transfer speed of the Flash storage in 3 seconds of I/O at 25MB/s. Arjan said that because of that we don’t read the while file, we read only the pieces of the file we actually use. Its easy for the disk if it anything else needs it can get from sReadahead as its uses the “idle” I/O scheduler. The system boots in seven seconds having readahead turned off but with readahead it boots in five seconds.
Arjan said that X is still having difficulty so we had to do a lot of damage to X. Most of work was temporary while some work involved eliminating the C compiler run by re-using keyboard mappings. To cut the total startup time the current line of X puts more of the hardware detection and configuration into the kernel. Some part of kernel’s time budget spends in waiting for hardware to initialize, though it can initialize more than one thing at a time so more efficient use of time for kernel is to initialize the video hardware at same time as it does USB and ATA. From audience X developer Keith Packard and also an Intel employee offered their help. By setting the video mode in the kernel, that would not let the kernel that would not let the kernel initialize it at the same time as the rest of hardware as shown in Fig.3. GDM is not used for fast booting system by running the XFCE desktop environment it boots straight to a user session. Arjan said that instead of GDM a distribution could boot to the desktop session of the last user but for that start the screen saver right away. By that a different user wanted to log in then he of she can use the screen saver’s “switch user” button.
At end Arjan said that don’t settle for making boot faster that’s the wrong question. The question is ‘ make boot fast’. A few people run a filesystem that requires a module or send mail on their laptops so don’t make all users wait. Make it like that you only pay the price if you use the feature. He said that distributions shouldn’t have to maintain separate initrd-based and initrd-free kernel packages. The kernel can try to boot initrd-free, then fall back for any reason like it cant see /sbin/init, as the module needed to mount the root filesystem is missing.