Analysis of Linux boot process under X86 architecture

Source: Internet
Author: User

1. The overall process of booting from boot to start_kernel underX86 architecture

A brief overview of this process is:

Boot-->bios-->grub/lilo-->linux Kernel

Its running flowchart and important functions are as follows:

2, load the Linux Kernel (based on X86) memory layout map

| |

0a0000 +--------------------------+

| Reserved for BIOS | Do not use. Reserved for BIOS Ebda.

09a000 +--------------------------+

| Command Line |

| Stack/heap | For use by the kernel Real-mode code.

098000 +--------------------------+

| Kernel Setup | The kernel Real-mode code.

090200 +--------------------------+ <---__start function start execution address

| Kernel Boot Sector | The kernel legacy boot sector.

090000 +--------------------------+ <---header. S

| Protected-mode Kernel | The bulk of the kernel image.

010000 +--------------------------+

| Boot Loader | <-Boot Sector entry point 0000:7C00

001000 +--------------------------+

| Reserved for Mbr/bios |

000800 +---------------------------+

| Typically used by MBR |

000600 +--------------------------+

| BIOS Use only |

000000 +--------------------------+

3. Start

2.BIOS boot -boot phase

The BIOS calls Bootloader to load the kernel image of the operating system into the system RAM .

(1), whenPCwhen the power supply is turned on,80x86Architecture ofCPUwill automatically enter real mode and from the address0xffff0(CS:0xFFFF,IP:0x0) to start executing the program code automatically, this address is usuallyBIOS's address.
(2), BIOSthe first to proceedPOST(PowerOn self test is a post-power-on test that detects the presence and functioning of some critical devices in the system, such as memory and graphics. The video card is not initialized at this point, and if some fatal errors are found, such as no memory or memory problems (this will only check640Kconventional memory),BIOSDirect control of the Speaker's voice to report errors, the length and number of times the sound represents the wrong type.
(3), then physical address0start initializing the interrupt vector (Note: thisBIOSthe interrupt vector is important, and many of the other interactions with the hard disk are done through this interrupt vector.
(4), thereafter,BIOSthe first sector of the device will be started(Section0The first sector of the track is calledMBRWhich is the master boot record, the size of which is +bytes, which are stored insidePre-boot information written in assembly language, partition table information, magic number 0X55AA), read into the memory absolute address0x7c00Place, and jump to thisAddress and execute it. is actually copied to physical memory0x7c00the content of the office isBoot Loader, for the older kernel is not dependent onGrubstart, it's theBootsect. Sprogram, and for nowPCmost useGrubthe boot-up isLiloorGrubup.

3.Bootloader stage

Bootloaderprograms are loaded for the computer (Load) ComputerOS kernel.bootloaderThe program is usually located on the hard disk and isBIOScalled to load the kernel. In thePCcommon on-machinebootloadermainly hasGruband Liloand so on.
Grub(GRand Unified Bootloader) is the currentLinuxThe default bootstrapper for many release versions. On embedded systems, the most commonbootloaderis aU-boot. Such abootloadergenerally located inMBRthe front of the car. In theLinuxSystem,bootloaderyou can also write to the partition where the file system resides. For example,GrubThe program is very powerful. Gurbonce run, the environment required to set the kernel to run will be initialized. Then load the kernel image. Grubdisk boot whole process:

(1)stage1, Grub reads The primary boot record for the first byte of the disk MBR.

(2)stage1. 5, to identify a variety of file system formats, the purpose is to grub can recognize the file system.

(3)stage2, loading the System boot Menu (/boot/grub/menu.lst or grub.lst), Load kernel vmlinuz and RAM disk initrd.

4.Linux kernel boot process

Kernel image file vmlinuz: An executable file containing a static link to the linux kernel, traditionallyknown asvmlinux , is called a bootable kernel image. Vmlinuz is a compressed file of Vmlinux. Its composition includes:

1 . First 512-byte bootsect (first block)

2, the second is the setup code, a few more than 512 bytes (one will say how big it)

3 protected Mode kernel code
    bzimage file: Using make bzimage command to compile the kernel source code, you can get the use of zlib algorithm compression zimage file, which is big zimage file. Old zimage Unzip the kernel to low-end memory, bzimage Unzip the kernel to high-end memory ( 1m ( 0x100000

The Bzimage file consists of Setup and Vmlinux, Setup is the code in real mode, and Vmlinux is the code in protected mode. Specifically includes vmlinuz,bootsect.o,setup.o, unzip program MISC.O, and other related files (such as piggy.o).

Initramfs ( or initrd) file:initrd is initialized RAM disk the meaning. Mainly used to load the hardware driver module, the boot of the auxiliary kernel, mount the real root file system.

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.