我来我网
https://5come5.cn
 
您尚未 登录  注册 | 菠菜 | 软件站 | 音乐站 | 邮箱1 | 邮箱2 | 风格选择 | 更多 » 
 

本页主题: 看了下GRUB的引导,转一篇其关于它引导机制的简单介绍(Come from it's doc) 隐藏签名 | 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

goon83





性别: 帅哥 状态: 该用户目前不在线
等级: 品行端正
发贴: 349
威望: 0
浮云: 1146
在线等级:
注册时间: 2005-11-05
最后登陆: 2009-03-10

5come5帮你背单词 [ triangle /'traiængl/ n. 三角,三角形 ]


看了下GRUB的引导,转一篇其关于它引导机制的简单介绍(Come from it's doc)

有兴趣的可以看看它的文档,不过不太全,最好是看它的源代码:~ ^~:


D.5 The bootstrap mechanism used in GRUB

The disk space can be used in a boot loader is very restricted because a MBR (see section The structure of Master Boot Record) is only 512 bytes but it also contains a partition table (see section The format of partition tables) and a BPB. So the question is how to make a boot loader code enough small to be fit in a MBR.

However, GRUB is a very large program, so we break GRUB into 2 (or 3) distinct components, Stage 1 and Stage 2 (and optionally Stage 1.5). See section The memory map of various components, for more information.

We embed Stage 1 in a MBR or in the boot sector of a partition, and place Stage 2 in a filesystem. The optional Stage 1.5 can be installed in a filesystem, in the boot loader area in a FFS or a ReiserFS, and in the sectors right after a MBR, because Stage 1.5 is enough small and the sectors right after a MBR is normally an unused region. The size of this region is the number of sectors per head minus 1.

Thus, all Stage1 must do is just load Stage2 or Stage1.5. But even if Stage 1 needs not to support the user interface or the filesystem interface, it is impossible to make Stage 1 less than 400 bytes, because GRUB should support both the CHS mode and the LBA mode (see section INT 13H disk I/O interrupts).

The solution used by GRUB is that Stage 1 loads only the first sector of Stage 2 (or Stage 1.5) and Stage 2 itself loads the rest. The flow of Stage 1 is:

1. Initialize the system briefly.
2. Detect the geometry and the accessing mode of the loading drive.
3. Load the first sector of Stage 2.
4. Jump to the starting address of the Stage 2.

The flow of Stage 2 (and Stage 1.5) is:

1. Load the rest of itself to the real starting address, that is, the starting address plus 512 bytes. The block lists are stored in the last part of the first sector.
2. Long jump to the real starting address.

Note that Stage 2 (or Stage 1.5) does not probe the geometry or the accessing mode of the loading drive, since Stage 1 has already probed them.
顶端 Posted: 2006-12-26 09:47 | [楼 主]
我来我网·5come5 Forum » Linux专区

Total 0.005737(s) query 4, Time now is:12-23 05:20, Gzip enabled
Powered by PHPWind v5.3, Localized by 5come5 Tech Team, 黔ICP备16009856号