Linux boot process detailed

Source: Internet
Author: User

Transferred from: http://blog.chinaunix.net/uid-26495963-id-3066282.html

Start the first step --load the BIOS
When you turn on the computer, the computer loads the BIOS information first , and the BIOS information is so important that the computer must find it at the very beginning. This is because the BIOS contains information about the CPU, device boot sequence information, hard disk information, memory information, clock information, PNP features, and so on. After that, the computer has a spectrum and knows which hardware device to read.

The computer is almost useless at the moment of the appliance because the RAM chip contains random data, which is the following steps when starting up :

    • A special one should generate a reset logic value on one pin of the CPU, and then set some registers (including CS and EIP) to a fixed value
    • Then execute the code found at the physical address of 0xFFFF FFF0, the hardware maps this address to a read-only, persistent memory chip, which is usually rom
    • And the assembly stored in the ROM is usually called the BIOS in the 80x86 body system.


start second step -read MBR
It is well known that the hard disk , which is the master boot record, which is the main boot recording, it is 512 bytes in size, but it is not small, but it is stored in the pre-boot information , partition table information.
After the system finds the MBR of the hard disk specified by the BIOS , it is copied to 0 x0000 7c00 The physical memory in which the address resides. The , and specifically to your computer, it's Lilo or grub (grub turns out to be bootloader).

start step three --boot Loader
Boot Loader is a small program that runs before the operating system kernel runs. With this applet, we can Initialize the hardware device, build a map of the memory space , and so that . There are several types of
Boot loader, where grub, Lilo, and spfdisk are common loader.
We use grub as an example to explain, after all, there are not many people with Lilo and Spfdisk. The
system reads the GRUB configuration information in memory (typically menu.lst or grub.lst) and launches a different operating system according to this configuration information.

    • The bootloader starts in RAM from the address of 0x0009 0200, and the setup () function is linked here and then jumps to setup () to start execution, initializing the hardware device again (the BIOS is initialized)
    • Setup () ends up jumping to startup_32 (), which extracts the kernel, which is referred to in the fourth step, and jumps to 0x0010 0000.
    • Executes the second startup_32 () function, which is the same as the previous function name, but differs from the starting physical address, and the end of the function jumps to Start_kernel ().
    • Executes Start_kernel (), which completes the initialization of the Linux kernel. , almost every kernel component is initialized by this function.


Start the fourth step --load the kernel
based on the path of the kernel image set by grub (Bootloader gives the image path), the system reads the memory image and does the decompression operation . At this point, the screen will generally output "uncompressing Linux" prompt. When the decompression core is complete, the screen output "OK, booting the kernel".
The system places the extracted kernel in memory and calls the Start_kernel () function to start a series of initialization functions and initialize the various devices to complete the Linux core environment. At this point, theLinux kernel has been established , Linux-based programs should be able to run properly.


start the fifth step -User layer init sets the operating level according to the Inittab file
After the kernel is loaded,first oneThe program that runs is/sbin/init, the file willRead/etc/inittabFile and initialize it according to this file.
In fact, the main function of the/etc/inittab file isset the Linux operating level, which is set in the form ": Id:5:initdefault:", which indicates that Linux needs to run on level 5. Linux runs at the following levels:
0: Turn off the machine
1: Single-user mode
2: Multi-user mode with no network support
3: Multi-user mode with network support
4: reserved, not used
5: Multi-user mode with network support with X-window support
6: Reboot the system, that is, restart
There is a lot of learning about/etc/inittab files.

start the sixth step --init Process Execution Rc.sysinit
After the operating level has been set, the Linux system performsfirst user-level fileIt is/etc/rc.d/rc.sysinitScripting, it does a lot of work, including setting path, setting network configuration (/etc/sysconfig/network), starting swap partition, setting/proc, and so on. If you are interested, you can go to/ETC/RC.D to see the Rc.sysinit file, inside the script enough to see you for a few days

start the seventh step --Start the kernel module
Specific is based on/etc/modules.confFile or/ETC/MODULES.DFiles in the directory to load the kernel modules.

start Eighth step --execute scripts with different RunLevel
Depending on the runlevel, the system will run the appropriate script from RC0.D to RC6.D to perform the appropriate initialization and start the appropriate service.

start the nineth step --Execute/etc/rc.d/rc.local
If you open this file, there is a word, read it, you will be the role of this command at a glance:
# This script is executed *after* all and the other init scripts.
# can put your own initialization stuff in here if you don ' t
# want to does the full Sys V style init stuff.
Rc.local is the place where Linux is left to the user for personalization after all initialization work。 You can put the things you want to set up and start up here.

start Tenth step --Execute/bin/login program, enter login status
At this time, the system has entered the waiting for the user input username and password, you can already use your own account login system. :)
===
The long start-up process is over, everything is quiet ...
In fact, behind this, there is a more complex underlying function call, waiting for you to study ... This article even to the following:)

A detailed description of the Linux boot process

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.