x86计算机启动过程

启动流程

  1. BIOS读取MBR(Master Boot record)
  2. MBR引导Bootloader(NTLOADER or GRUB or LILO…)
  3. Bootloader加载kernel
  4. init进程初始化

MBR结构

  • MBR只有512字节大小,存储在硬盘的0道0面1扇区
  • 引导代码(BootCode),446 bytes
  • 分区表(Partition table),64 bytes
  • Magic Number(55AA),2 bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
     -+-  +-------------------+
| | |
| | |
| | |
| | |
446 B | | Boot Code |
| | |
| | |
| | |
| | |
-+- +-------------------+
| | | +-------------------------+
64 B | | Partition | | Partition 1 |
| | Table | ---------> +-------------------------+
| | | | Partition 2 |
-+- +-------------------+ +-------------------------+
| | | | Partition 3 |
2 B | | Magic Number | +-------------------------+
| | | | Partition 4 |
-+- +-------------------+ +-------------------------+
|
|
v

+----------------+-----------+----------------+---------+-----------+------+
| Partition flag | Start CHS | Partition byte | End CHS | Start LBA | Size |
+----------------+-----------+----------------+---------+-----------+------+

参考文献