GRUB2及启动过程详解

  • 格式:docx
  • 大小:275.34 KB
  • 文档页数:47

GRUB2及启动过程详解

作者: 南瓜剪子

2016年7月28日

1. 概述 ............................................................................................................................................ 2

2. CentOS7中GRUB2 ..................................................................................................................... 2

3. GRUB2 的 bootstrap image文件 .............................................................................................. 3

3.1. boot.img ............................................................................................................................ 3

3.2. diskboot.img ...................................................................................................................... 4

3.3. kernel.img .......................................................................................................................... 4

3.4. core.img ............................................................................................................................. 4

3.5. *.mod ................................................................................................................................. 4

4. 对比GRUB Legacy ...................................................................................................................... 5

4.1. stage1 ................................................................................................................................ 5

4.2. *_stage1_5 ........................................................................................................................ 5

4.3. stage2 ................................................................................................................................ 5

5. grub2-mkimage定制core.img ................................................................................................... 6

6. GRUB2安装 ................................................................................................................................ 7

6.1. Linux是怎么命名设备(/dev/sda) ..................................................................................... 7

6.2. MBR(Master Boot Record) ................................................................................................. 8

6.3. MBR分区表DPT(Disk Partition Table) ........................................................................... 10

6.4. LBA and CHS..................................................................................................................... 14

6.4.1. CHS(cylinders-heads-sectors) ................................................................................ 14

6.4.2. LBA(Logical Block Address) .................................................................................... 14

6.5. boot.img和core.img安装 ............................................................................................. 15

6.6. 硬盘总结 ........................................................................................................................ 18

7. 启动过程................................................................................................................................... 19

7.1. BIOS ................................................................................................................................. 19

7.2. GRUB2中boot.img ......................................................................................................... 20

7.2.1. Step1无条件跳转 ................................................................................................ 20

7.2.2. Step2 初始化 ....................................................................................................... 20

7.2.3. Step3 判断硬盘是否支持LBA还是只支持CHS ................................................ 22

7.2.4. Step4 采用LBA加载core.img第一个扇区 ....................................................... 23

7.2.5. Step5 拷贝core.img第一个扇区到内存指定位置 ............................................ 25

7.2.6. Step6 执行core.img第一条语句 ....................................................................... 27

7.2.7. Step7 boot.img总结 ............................................................................................. 27

7.3. GRUB2中core.img.......................................................................................................... 28

7.3.1. diskboot.img .......................................................................................................... 28

7.3.2. GRUB2 core Startup .............................................................................................. 34

7.3.3. GRUB主函数即GRUB主要功能 ......................................................................... 37