Before you know the boot process, you need to know the basics of some disks. The disk is mainly composed of platters, mechanical arm, head and spindle motor. A platter is a physical unit that stores data. Then we can divide the disk into sectors (sector) and cylinders (cylinder), each sector sector to 512Bytes. As shown in the following:
After the partition is complete, each partition (file system) has a boot sector (boot sector), and the boot is the first sector of the entire disk, the sector is very important, composed of the following:
(1) Master boot partition (MBR) master boot record;446bytes; Install boot loader in this area when system is installed bootloader
(2) partition table (partion table); 64Bytes; record the partition state of the whole disk;
To understand the start-up process, there are two more concepts that have to be said: BIOS and CMOS. CMOS is a memory that records various hardware parameters and is embedded in the motherboard, and the BIOS is the first program that is executed on the boot, which confirms the boot order of the hardware device, and then finds the boot program in the corresponding hardware device.
OK, the following phases describe the start-up process of the boot.
First stage: BIOS
After power-up, the BIOS is the first program performed by the computer, the computer first performs a hardware self-test and, if there is an error, emits a different beep. After self-test, the BIOS will give control to the next stage of the boot process, but how to transfer it. Since the next stage of the boot program is placed in the boot sector (boot sector) of the disk partition, the BIOS will find a hardware device partition (which is what we usually say from a USB stick, hard disk, CD, etc.) based on the pre-programmed order of the boot sector.
Second stage: Master boot Record
It can tell the computer where to find the system. In addition, the MBR contains additional information. The distribution is as follows:
(1) 0-445, a total of 446Bytes, call the operating system machine code;
(2) 446-509, total 64Bytes, partition table information;
(3) 510-511, total 2Bytes, master boot Record signature (0X55,0XAA);
This inside the 1th and 3rd are relatively clear, but 2nd still need to dig a bit, partition table information contains what content? The following 6 parts are specified
(1) 0, 0x80, indicates that the partition is an active partition, 4 partitions can only have one active partition;
(2) 1-3, the physical location of the first sector of the primary partition (cylinder, head, fan area code, etc.);
(3) 4, primary partition type;
(4) 5-7, the physical location of the last sector of the primary partition;
(5) 8-11, the logical address of the first sector of the primary partition;
(6) 12-15, the total number of sectors of the primary partition;
The total number of sectors is 32bits, that is, if the size of each sector is 512Bytes, then the size of each partition is up to 2 32 bytes, or 2TB.
So far, the computer has found the bootloader.
Phase three: Hard drive boot
This is divided into the following 3 kinds of situations.
(1) Volume boot record
This is the simplest way to start, in four partitions only one is activated, find the first sector of the active partition (Volume boot RECORD:VBR), and then the boot program to load the system kernel boot system can be;
(2) Extended partition record
Since the drive is now getting bigger and larger, 4 partitions are not supported enough, so there is only one primary partition that can be defined as an extended partition, and then logically extended in the extended partition, which is the logical partition. The boot record is located in the first sector of the extended sector, called an extended boot record (extend boot Record:ebr). In this sector, there is also a partition table, but this partition table has only two partition information. The computer finds the next logical partition based on the second partition, and then does the same thing in the first sector of the next logical partition, finds the third logical partition, loops down until it finds its logical partition, which is the last logical partition.
(3) Boot Manager
The main purpose of this is to install multiple operating systems, to find the master boot record is not to give control to a partition but to the already installed "boot Manager" BootLoader, by the user to select an operating system. Grub is the most popular boot manager for Linux environments.
Startup process under Linux system