LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1877|回复: 7

请教--一个grub的问题

[复制链接]
发表于 2007-3-1 15:26:40 | 显示全部楼层 |阅读模式
下面是grub.conf里面的截取:
title Red Hat Enterprise Linux AS (2.6.9-34.ELsmp)
root (hd0,0)
kernel /boot/vmlinuz-2.6.9-34.ELsmp ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.9-34.ELsmp.img

请问当系统开始引导,引导到安装在mbr的grub的时候,grub通过什么来找到配置文件里面写的
/boot/vmlinuz(kernal 压缩文件)的位置呢?
是通过cylinder  head sector block的位置吗?
发表于 2007-3-1 15:39:57 | 显示全部楼层
你想的太多了!
root(hd0,0) 这句的意识就是挂接第一硬盘的第一分区! 然后的文件读取都是逻辑相关的了!
如果你不使用root(hd0,0)的方式也可以使用:
kernel (hd0,0)/vmlinuz-* ..... 这样的方式找到文件!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-1 18:19:51 | 显示全部楼层
我还是比较迷茫
请问文件系统的驱动模块还没有加载
如何通过逻辑分区找到内核文件的呢?
还是有什么底层的东西?
thx!!!:beat
回复 支持 反对

使用道具 举报

发表于 2007-3-1 22:27:54 | 显示全部楼层
仔细看看 grub 的info !
提示 : 仔细看看 stage1 , stage1_5 , stage2 的加载过程和其作用!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-2 16:14:15 | 显示全部楼层
kevin 老师我看了半天info
但是还是没找到kernel命令是如何识别到partition里面的内核文件名呢?
是否grub程序默认就内置了linux或者bsd文件系统的驱动程序?
望释疑
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-2 16:18:01 | 显示全部楼层
他说可以通过两种方法:
一种是normal的 partition
另外一种是block list.
搞不懂........
回复 支持 反对

使用道具 举报

发表于 2007-3-2 17:36:43 | 显示全部楼层
`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.



以上的文件都是通过block list的方式load内存中的!有了*_stage1_5 , 内存中的grub 就可以通过root命令mount相应的文件系统到内存中,然后grub可以通过kernel和initrd命令load 可爱的内核!

在Grub 的文档中有
11.2 How to specify files

There are two ways to specify files, by absolute file name and by block list.

An absolute file name resembles a Unix absolute file name, using `/' for the directory separator (not `\' as in DOS). One example is `(hd0,0)/boot/grub/menu.lst'. This means the file /boot/grub/menu.lst in the first partition of the first hard disk. If you omit the device name in an absolute file name, GRUB uses GRUB's root device implicitly. So if you set the root device to, say, `(hd1,0)' by the command root (see root), then /boot/kernel is the same as (hd1,0)/boot/kernel.

ext3是向下兼容的,有e2fs_stage1_5就可以mount ext3文件系统了,当然mount到内存的时候是以ext2文件系统的方式,所以我们一般是ro 只读的方式去访问!
如果你的kernel是在一个软raid上,grub目前只支持raid1 !
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-4 20:49:51 | 显示全部楼层
哦.终于有些搞明白了,我再去仔细看看相关文档;
非常感谢!!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表