Introduction to motherboard program (BIOS / UEFI), disk partition type (MBR / GPT)

1. Motherboard built-in program:

BIOS (Basic Input Output System): Basic Input Output System.
UEFI (Unified Extensible Firmware Interface): Unified Extensible Firmware Interface, a new program used to replace BIOS.

1.1 Function

The built-in programs of these two motherboards are similar in function, nothing more than initializing the hardware, detecting hardware information, and then booting the system on the hard disk to run.

1.2 Comparison

Let me say a few points of comparison that are more useful to users
(1) Process:
BIOS:

上电自检
初始化硬件
加载MBR...
系统启动引导代码
启动系统内核
系统启动完成

UEFI:

上电自检
初始化硬件
加载UEFI固件
启动UEFI应用
启动系统内核
系统启动完成

(2) The matching partition type:
BIOS: the disk whose partition type is MBR can be used normally
UEFI: the disk whose partition type is GPT can be used normally

(3) Speed ​​and flexibility:
BIOS: The traditional BIOS program is relatively stupid to run. It can basically only manage the hardware part, and will not interact with the system.
UEFI: Compared with the traditional BIOS, it starts faster. The traditional BIOS cannot store hardware information, and resources must be redistributed to these hardware every time it is powered on; while UEFI can store configuration information, and the hardware is not replaced every time it is powered on. Finally, you only need to allocate resources according to the configuration information. For more complex devices, UEFI can also allow the hardware itself to store its own configuration information, and provide an API to cooperate with the operating system to initialize the hardware, speeding up the operation of the system.

2. Disk partition

There are two types of disk partitions, MBR and GPT.

2.1 MBR type partition structure

MBR (Master Boot Record): Master Boot Record
insert image description here
● Master Boot Program (MBR): After the BIOS initialization is completed, the master boot program in sector 0 of the disk will be loaded into the memory to run. And here it 主引导程序will find the active partition, 活动分区中的引导程序(一般占一个扇区大小,即512字节)load it into the memory and run it, and then jump to the program boot that can actually boot the operating system (bootloader or GRUB2, etc. as shown in the figure below) and run the windows kernel program.

第一阶段引导
第二阶段引导
主引导程序
活动分区中的引导程序
bootloader / GRUB2等
操作系统内核

BootLoader: used to guide windows vista, 7, 8, 10
GRUB2: used to guide the operating system of linux

● Partition table (DPT): The disk in MBR format has only four partition tables, each partition table occupies 16 bytes, and corresponds to a certain primary partition in the disk. Because there are only four primary partition tables, there can only be disks with MBR type partitions. If 四个主分区you want more partitions, you can only change one of the primary partitions into an extended partition (a disk can only have one extended partition at most), and then the extended partition can be divided into Several logical partitions come out.

Byte bit content and meaning
0x000 If it is 80H, it means the partition is an active partition; if it is 00H, it means it is an inactive partition. A disk can only have one active partition, and the active partition generally stores the operating system
0x001~0x003 The address of the first sector of this partition (head number, cylinder number, sector number)
0x004 This partition type
00H: This partition is not used
05H: Extended partition
06H: FAT16 type
07H: NTFS type
0BH: FAT32 type
0x005~0x007 The address of the last sector of this partition (head number, cylinder number, sector number)
0x008~0x011 Four bytes represent the total number of sectors before this partition, so the maximum total capacity before each partition is: 2^32 * 512 = 2TB
0x012~0x015 Four bytes represent the total number of sectors of this partition, so the maximum capacity of each partition: 2^32 * 512 = 2TB

Combining with 8 ~ 11位and 12 ~ 15位we can see that in theory, MBR partitions only support disks with a maximum capacity of 4TB. In reality, the Windows system can only allocate a maximum capacity of 2TB in the partition management. If you want to allocate 4TB, you need to use a third-party tool to partition (but this is not recommended, otherwise you will bear the consequences)

● End mark: two bytes, 0x55 and 0xAA, if not, BIOS will think that this disk cannot be booted correctly, and BIOS will continue to check the next disk in the disk list. If all disks are invalid, a boot class error will be reported.

The entire first sector above corresponds to the content in the red box in the figure below:
insert image description here
Note: The tool for viewing disk byte data in the figure above is called winhex

2.2 GPT type partition structure

GPT (GUID Partition Table): globally unique identifier disk partition table
insert image description here

● [LBA0] Protective MBR (Protective MBR): Occupies a sector size, the format is consistent with the normal MBR partition, but most of the rest are 0 except for the ending mark or 0x55 and 0xAA. On a disk with only GPT partitions, this part is only for the previous MBR disk tool to correctly identify the disk and prevent disk damage caused by misoperation.
insert image description here

● [LBA1] GPT Header (Primary GPT Header): Occupies a sector size, and the specific meaning is shown in the table below

Byte bit Bytes content and meaning
0x200~0x207 8 The signature of the GPT header is translated into EFI PART through ascii code conversion
0x208~0x20B 4 version number
0x20C~0x20F 4 The size of meaningful data in the GPT header is generally 92 bytes, and the remaining 420 bytes are all filled with 0
0x210~0x213 4 CRC checksum of the GPT header
0x214~0x217 4 Must be "00 00 00 00"
0x218~0x21F 8 The starting sector number of the GPT header
0x220~0x227 8 The GPT header backup sector number, as shown in the figure above, is generally the last sector
0x228~0x22F 8 The starting sector number (LBA34) that can be partitioned
0x230~0x237 8 The end sector number that can be partitioned (the 34th sector from the bottom)
0x238~0x247 16 Disk GUID (also called UUID in UNIX-like systems)
0x248~0x24F 8 The starting sector number of the partition table (LBA2)
0x250~0x253 4 The total number of partition tables, because the windows system limits its maximum to 128, so theoretically windows can divide up to 128 partitions
0x254~0x257 4 The number of bytes occupied by each partition table, usually 128bytes
0x258~0x25B 4 CRC checksum of all partition tables
0x25C~0x3FF 420 Reserved bits, all 0

insert image description here

● [LBA2~LBA33] Partition table: Each partition table entry occupies 128 bytes, and because Windows can support a maximum of 128 partitions, so on a disk with Windows system, the number of bytes occupied by the entire partition table entry is = 128 bytes * 128 = 16384 bytes = 32 LBA sizes. The format of each partition table entry is as follows (take the first partition table entry as an example)

Byte bit Bytes content and meaning
0x400~0x40F 16 The partition type, GUID indicates
0x410~0x41F 16 The unique identifier of the partition, GUID means
0x420~0x427 8 The starting sector of the partition, unit: LBA
0x428~0x42F 8 The end sector of the partition, unit: LBA
0x430~0x437 8 The partition attribute flag
0x438~0x47F 72 The partition name of the partition, up to 32 characters, usually these characters are encoded in UTF-16

See the table below for partition attributes (8 bytes=8*8bit=64bit):

bit content and meaning
0 System partition (disk partition tool must keep this partition as it is without any modification)
1 EFI hidden partition (EFI invisible partition)
2 Bootable partition flag for legacy BIOS
60 read only
62 hide
63 Do not automatically mount, that is, do not automatically assign a drive letter

See the table below for partition types:

operating system GUID (little endian) content and meaning
None 00000000-0000-0000-0000-000000000000 Unused
None 024DEE41-33E7-11D3-9D69-0008C781F39F MBR partition table
None C12A7328-F81F-11D2-BA4B-00A0C93EC93B EFI system partition
None 21686148-6449-6E6F-744E-656564454649 BIOS boot partition
None D3BFE2DE-3DAF-11DF-BA40-E3A556D89593 Intel Fast Flash (iFFS) partition (for Intel Rapid Start technology)
Windows E3C9E316-0B5C-4DB8-817D-F92DF00215AE Microsoft Reserved Partition
Windows EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 basic data partition
Windows DE94BBA4-06D1-4D40-A16A-BFD50179D6AC Windows recovery environment
Linux 0FC63DAF-8483-4772-8E79-3D69D8477DE4 Data partition. Linux used to use the same GUID as the Windows base data partition. This new GUID was invented by the GPT fdisk and GUID Parted developers based on Linux's traditional "8300" partition code.
Linux A19D880F-05FC-4D3B-A006-743F0F84911E RAID partition
Linux 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F swap partition
Linux E6D6D379-F507-44C2-A23C-238F2A3DF928 Logical Volume Manager (LVM) partitions
Linux 8DA63339-0007-60C0-C436-083AC8230908 reserve

The following are three types of partition tables, corresponding to the partition types in red, blue, and black fonts in the above partition type table
insert image description here

3. Summary

The UEFI+GPT solution has gradually faded out of the market due to its advantages in terms of unlimited disk capacity and operating speed. Therefore, it is recommended that if you install a system that supports UEFI+GPT, you can give priority to the UEFI+GPT solution.

Guess you like

Origin blog.csdn.net/In_engineer/article/details/123523455