Top Technology 1 seconds to start Linux tips

Source: Internet
Author: User

is it possible to start Linux in 1 seconds? We know that Linux system boot is not fast, at least 11 seconds, but now there is a trick, can 1 seconds to open the Linux system, what is the technology so cattle? See below for more information

Starting the system as fast as possible is very important for automation equipment. The system can be started in a time that the user cannot perceive, which means that the power can be completely cut off when no work is needed, instead of suspending into hibernation. based on the Atmel AT91 series on-chip systems and NAND flash, this article has been optimized to reduce the startup time of the Linux system from the initial 11 seconds to the final 656 milliseconds .

Background knowledge

The system needs a lot of process from power up to full boot. a simplified start-up process might include:

• Hardware Reset

• Boot bootloader (bootloader)

• Operating system initialization

• Application Execution

Hardware is critical, but hardware is generally difficult to change. Subsequent optimizations are primarily for boot programs, Linux kernels, and application deployment.

Bootloader optimization

The bootloader mainly completes the basic CPU setting, handles the ARM tag (atags,arm tags) or device tree (devices trees), switches the Storage Management Unit (Mmu,memory Management unit) and so on.

For U-boot, the commonly used optimization methods are:

• Remove the features you don't want: such as network loading, if not, remove the code directly.

• Turn off unwanted features

• Turn off kernel mirroring verification

• Turn off bootloader output

• Turn off startup delay

The generic functionality of the bootstrapper is modified to an optimized initial loader (Initial program LOADER,IPL), for U-boot, can be achieved through SPL (Second program Loader, the second stage loader).

Kernel Optimizations

The Linux kernel is designed to be very flexible and can be configured to optimize for all the features needed. Therefore, optimizing the kernel is critical for system boot speed.

first of all, remove all the drivers, reduce the kernel load content, can greatly shorten the system startup time. Second, there are many kernel options that may require further attempts, such as kernel compression, and lzo compression is usually a good choice for embedded systems. Finally, a number of startup parameters can be customized to speed up the start-up. For example, you can use the "lpj=" parameter to preset the value of the number of Beats (loops per JIFFY,LPJ) required for Each loop to prevent the system from automatically projecting at startup . This saves up to 100ms of time in ARMV5-based systems.

For kernel-initiated optimizations, the kernel boot time-consuming chart can be drawn through the bootgraph.pl script (script/bootgraph.pl in the kernel source) to analyze where the startup takes time. This script uses a very simple, direct DMESG output as its input, you can generate an SVG diagram:

DMESG Perl scripts/bootgraph.pl > Output.svg

The resulting chart is as follows:

Each color segment in the diagram represents the time-consuming initialization of a function. You can simply turn off unwanted features or make specific optimizations for features.

In addition to the kernel itself, the file system in which the kernel resides has a very large impact on system startup. UbiFS is a good choice for systems that use flash memory chips as storage . It can tolerate accidental power outages and has excellent mount speeds to ensure fast system start-up.

Application optimization

After the kernel completes the system startup, the next step is to execute the application. For the optimization of the application, there are two main parts, part of which is the application to take over the INIT process initiated, and the other part is to optimize the way the application is linked.

The standard SYSTEMV init program requires a bunch of startup scripts to execute. For embedded systems, most of them are meaningless. Another part (such as mounting a file system) can be implemented by the application itself. The init process can then be specified directly as an application by using the "init=" parameter in the kernel startup parameters.

Application-dependent dynamic-link libraries are searched in the following order:

ld_preload The path specified by the environment variable (generic counterpart file/etc/ld.so.preload);

elf. The path specified by the Dt_rpath entry in the dynamic section, if the Dt_runpath entry does not exist;

• The environment variable ld_library_path the specified path, but if the executable file has Setuid/setgid permissions, the path is ignored, and the specified –library-path overwrites the path at compile time;

elf. The path specified by the Dt_runpath entry in the dynamic section;

Ldconfig The path in the cache (usually corresponding to the/etc/ld.so.cache file), if the compile time using the-Z nodeflib link option, then this step skipped;

/lib, and then/usr/lib path, if you use the-Z nodeflib link option, this step is also skipped;

As a result, the link speed can be accelerated by placing the dynamic link library that the application relies on to the path of the preferred lookup . for a cross-compilation environment, it is important to note that the dynamic link library location on the host and the location on the target system may be inconsistent, which increases the load time of the dynamic-link library when the application executes.

Summarize

Based on the three optimization points mentioned above, the system's start-up time can be reduced from the initial 11s to 656ms(data reference to the speech at the embedded Linux conference held in Dublin by Altenberg). From the hardware to the boot program to the end of the kernel to the application, each boot step has its own optimizations, and with some simple optimizations, it can reduce the system startup time.

Related recommendations:

A graphics tutorial that launches Linux ISO images directly from the hard disk

Workaround for Linux system cannot start after modifying Fstab file

Top Technology 1 seconds to start Linux tips

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.