免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: colinfloyd
打印 上一主题 下一主题

Grub 是如何读取到 /boot 下的设置文件的? [复制链接]

论坛徽章:
0
11 [报告]
发表于 2010-01-08 10:05 |只看该作者
原帖由 Celinde 于 2010-1-7 23:44 发表


lilo不依赖文件系统,也能读取内核,他记下了内核在硬盘上的位置,然后调用bios读取..


楼上的意思是说,Grub是合逻辑的,而lilo是不合逻辑的?
我是说,Grub是在识别了文件系统之后再找内核,而lilo是直接找硬盘上的数据的?

论坛徽章:
0
12 [报告]
发表于 2010-01-08 11:05 |只看该作者
我可没说lilo不符合逻辑..
我说lilo不通过文件系统找内核。

只要你记住了文件放在硬盘上哪个柱面哪个磁道哪个扇区,杀过去直接读,不就读到了..

论坛徽章:
0
13 [报告]
发表于 2010-01-08 12:34 |只看该作者
对于ext2这样的inode和数据分开的文件系统,lilo找到没问题,但对于fat恐怕就不行了吧?

论坛徽章:
0
14 [报告]
发表于 2010-01-08 12:57 |只看该作者
  谁那么BT,把内核放FAT上..

招聘 : 技术支持/维
论坛徽章:
0
15 [报告]
发表于 2010-01-16 00:19 |只看该作者

回复 #1 colinfloyd 的帖子

学习

论坛徽章:
0
16 [报告]
发表于 2010-01-16 01:03 |只看该作者
这是我前年研究过的小东东,讲的很详细了,gnu的解释为:

10 GRUB image files
GRUB consists of several images: two essential stages, optional stages called Stage 1.5, one image for bootable CD-ROM, and two network boot images. Here is a short overview of them. See Internals, for more details.

stage1
This is an essential image used for booting up GRUB. Usually, this is embedded in an MBR or the boot sector of a partition. Because a PC boot sector is 512 bytes, the size of this image is exactly 512 bytes.
All stage1 must do is to load Stage 2 or Stage 1.5 from a local disk. Because of the size restriction, stage1 encodes the location of Stage 2 (or Stage 1.5) in a block list format, so it never understand any filesystem structure.


stage2
This is the core image of GRUB. It does everything but booting up itself. Usually, this is put in a filesystem, but that is not required.

e2fs_stage1_5
fat_stage1_5
ffs_stage1_5
jfs_stage1_5
minix_stage1_5
reiserfs_stage1_5
vstafs_stage1_5
xfs_stage1_5
These are called Stage 1.5, because they serve as a bridge between stage1 and stage2, that is to say, Stage 1.5 is loaded by Stage 1 and Stage 1.5 loads Stage 2. The difference between stage1 and *_stage1_5 is that the former doesn't understand any filesystem while the latter understands one filesystem (e.g. e2fs_stage1_5 understands ext2fs). So you can move the Stage 2 image to another location safely, even after GRUB has been installed.
While Stage 2 cannot generally be embedded in a fixed area as the size is so large, Stage 1.5 can be installed into the area right after an MBR, or the boot loader area of a ReiserFS or a FFS.


stage2_eltorito
This is a boot image for CD-ROMs using the no emulation mode in El Torito specification. This is identical to Stage 2, except that this boots up without Stage 1 and sets up a special drive `(cd)'.

nbgrub
This is a network boot image for the Network Image Proposal used by some network boot loaders, such as Etherboot. This is mostly the same as Stage 2, but it also sets up a network and loads a configuration file from the network.

pxegrub
This is another network boot image for the Preboot Execution Environment used by several Netboot ROMs. This is identical to nbgrub, except for the format.



[root@company grub]# ll /boot/grub/|grep 1_5
-rw-r--r-- 1 root root   7584 Dec  7  2008 e2fs_stage1_5
-rw-r--r-- 1 root root   7456 Dec  7  2008 fat_stage1_5
-rw-r--r-- 1 root root   6720 Dec  7  2008 ffs_stage1_5
-rw-r--r-- 1 root root   6720 Dec  7  2008 iso9660_stage1_5
-rw-r--r-- 1 root root   8192 Dec  7  2008 jfs_stage1_5
-rw-r--r-- 1 root root   6880 Dec  7  2008 minix_stage1_5
-rw-r--r-- 1 root root   9248 Dec  7  2008 reiserfs_stage1_5
-rw-r--r-- 1 root root   7072 Dec  7  2008 ufs2_stage1_5
-rw-r--r-- 1 root root   6272 Dec  7  2008 vstafs_stage1_5
-rw-r--r-- 1 root root   8896 Dec  7  2008 xfs_stage1_5
[root@company grub]# ll /boot/grub/|grep 1_5|wc -l
10
[root@company grub]#

[ 本帖最后由 yumanifold 于 2010-1-16 01:11 编辑 ]

论坛徽章:
20
CU大牛徽章
日期:2013-03-13 15:29:072015亚冠之阿尔希拉尔
日期:2015-09-12 09:33:562015年亚冠纪念徽章
日期:2015-09-22 17:12:202015亚冠之本尤德科
日期:2015-10-29 16:18:18神斗士
日期:2015-11-23 13:37:23青铜圣斗士
日期:2015-12-07 10:14:28平安夜徽章
日期:2015-12-26 00:06:3015-16赛季CBA联赛之佛山
日期:2016-01-18 08:59:06shanzhi
日期:2016-06-17 17:59:3115-16赛季CBA联赛之同曦
日期:2016-11-03 14:43:552015七夕节徽章
日期:2015-08-21 11:06:17丑牛
日期:2014-12-30 16:06:17
17 [报告]
发表于 2010-01-16 16:59 |只看该作者

论坛徽章:
0
18 [报告]
发表于 2010-01-28 16:14 |只看该作者
一般的文件系统,stage1.5应该是直接是MBR后面的32K吧。不知道写在MBR中的stage1用哪一个字节编码的stage1.5的位置,好像没有查到过。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP