Understand the boot-up procedure of Linux in Depth

            Understand the boot-up procedure of Linux in Depth  
This article will analyses the procedure of Linux Boo-up, it will cover but not limited of BOIS, LILO and GRUB boot-loader, as well as image files, bootsect , setup, vmlinux. etc. it will discuss together with loading, the mechanism of    boot-up and real code system to show you a whole picture.
We all realize that the bootup takes a long time at the beginning of learning Linux, therefore, why is it so slow, the following documentation will help the beginner to get familiar with Linux:
1.       Load
To make it simple, all the load thing is happened after the computer get power, for example, POST, the copy ad deploy of boot-loader, copy and deploy of the kernel, etc. all these steps are called “bootstrap”, we can divide them in 5 steps:
a.       BIOS
The storage mechanism of modern OS is designed to be volatile, once the power is shut down; the data in the memory will disappear, as well as the image of the OS itself. So we have to find a way to save the image of the OS(kernel) into a nonvolatile media, in the purpose of loading it once the power is turned on, so as to move to next step. This is load, also called bootstrap. This nonvolatile media can be hard disk, floopy or EPROM or Flash, also a node in the network. Go make the load happen, the OS need CPU run a short program when the machine is turned on, this short program must be stored in EPROM or Flash as a part of the OS memory. The true is, all kinds do CPU has been designed to the way that when the power is on, something happens in some place immediately, and the nonvolatile media is in the same place. CPU is shocked by electric, and then something happen; RAM chip will find the BIOS, then processor runs the BIOS code.
Nest, what BIOS does is to do a serial of testing, check what devices the OS have and if they could work smoothly. During this period, the version of BIOS will be shown. When the test touches some device which is available, initialization happen, it will end up with showing some device information.
The code of load is small and weak, it is hard for it to read and transfer the giant image of the OS from hard disk, so the concept of   boot section is advised, the program stored in “boot secter” helps BOIS to finalize the load of OS. But he maximum of sector is just 512b, so very limited information and date could be stored there. In one word, the boot code is a graduated procedure, it spits in different corners. When BOIS copies the content of the first sector to RAM accordingly, then the OS will jump there and execute the right code.
b.      Boot loader
It is a tough task for the small program, so it need to be KISS,   the source code bootsect.S is for the Linux boot sector, after compile, assemble and connection, generate to 3 parts: bootsect for boot sector, setup for bootstrap and image of kernel, named vmlinux! To be strict, bootsect and setup is not a part of kernel.
In one word, the boot load takes charge of putting the image of kernel to RAM, then it is done.
c.       Setup
Although the BIOS had tested the device, setup() will do it again in its own way and initialize the environment for the kernel.
2.       BOOTUP
When the image of kernel is transferred to RAM, after more than 10 rounds though,  which means the load is done, the boot-up has begun. Kernel takes over the ownership and start its career.
a.       Startup_32
The step is mainly about the initialization of CPU itself. Main CPU takes more responsibility then secondary CPU, but the later one also takes participant.
b.      Start_kernel
Initialization of the system resource by main CPU.
c.       Init()
Initialization most closely to the user layer, responsibility depends on the competition result, main CPU actually takes it.
Then Init will select a run level according to /etc/inittab,
 
 
 

你可能感兴趣的:(procedure,of,the,Understand,boot-up)