比如说我有一块硬盘,分成很多区。在其中的两个区上(/dev/sda1, /dev/sda2)装了两个linux系统。
我都没有分出单独的/boot,那就是在 /dev/sda1 和 /dev/sda2上都有 boot/grub目录。保存了自己的
grub.cfg。
但是整个磁盘的MBR只有一块,而且是写如磁盘的。 那么这个MBR运行的时候,怎么知道是去
/dev/sda1还是/dev/sda2上的boot/grub上去找呢?
--
Wizard
--
Wizard
--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
set root是在grub.cfg里面的吧。 所以是要先找到grub.cfg,再读这个配置文件吧。
那MBR中的程序,怎么找到grub.cfg的呢?
--
Wizard
好吧, 我的分区如下:
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 133371629 66684791 7 HPFS/NTFS/exFAT
/dev/sda2 133371904 523997183 195312640 83 Linux
/dev/sda3 523997184 527902719 1952768 83 Linux
/dev/sda4 527902720 976771071 224434176 83 Linux
能看出来,我启动的时候是从哪个盘上去找grub.cfg么?
你说的引导区是MBR么?
--
Wizard
--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
那是不是可以这么理解。 当已经读到grub.cfg的时候,其实已经完成了grub stage2的工作?
>
> On Friday, August 31, 2012, 馒头簸箕 wrote:
>>
>> 你的活动分区是第一个Win分区,这样能启动Linux?
>>
>> 在 2012-8-31,下午4:30,Wizard <wizard...@gmail.com> 写道:
>>
>> 能看出来,我启动的时候是从哪个盘上去找grub.cfg么?
>>
>>
>> --
>> -- You received this message because you are subscribed to the Google
>> Groups Shanghai Linux User Group group. To post to this group, send email to
>> sh...@googlegroups.com. To unsubscribe from this group, send email to
>> shlug+un...@googlegroups.com. For more options, visit this group at
>> https://groups.google.com/d/forum/shlug?hl=zh-CN
>>
>>
>
>
>
> --
> Liang Guo
> http://bluestone.cublog.cn
>
> --
> -- You received this message because you are subscribed to the Google Groups
> Shanghai Linux User Group group. To post to this group, send email to
> sh...@googlegroups.com. To unsubscribe from this group, send email to
> shlug+un...@googlegroups.com. For more options, visit this group at
> https://groups.google.com/d/forum/shlug?hl=zh-CN
>
>
--
Wizard
能,这就是我现在用的机器, 现在我在ubuntu下。
而且我还装了两个ubuntu,都能启动。
> 在 2012-8-31,下午4:30,Wizard <wizard...@gmail.com> 写道:
>
> 能看出来,我启动的时候是从哪个盘上去找grub.cfg么?
>
>
stage1 在mbr,有stage1.5/stage2在磁盘的偏移,大小信息。stage1运行后,载入stage1.5/stage2,并运行。
stage1.5/stage2 在文件系统中,有grub.cfg 的位置信息。是么?
想知道是stage1还是stage1.5/stage2知道这个配置文件的位置信息。
那每次grub-install时
1. 要修改mbr,使mbr有stage1.5/stage2的位置信息。
2. 要修改stage1.5/stage2中的grub.cfg的信息,让它找到正确的grub.cfg
right?
> 至于active,则是dos时代的遗留产物。dos时代的启动代码太简单了,无法显示个窗体给你选择。因此在设计分区表的时候,加入了active
> flag。如果有多个分区,那么第一个有active
> flag的分区就是要启动的目标。通常这时的mbr是一段链式引导代码,而不是msdos的引导扇区代码。链式引导代码会将自身搬移到其他位置,然后读取active分区的第零个扇区到0000:7c00的位置,再jmp过去。
> 好久没接触dos的代码了,不知道有没有记错。
>
> 在 2012年8月31日 下午10:57,Liang Guo <bluesto...@gmail.com>写道:
>>
>> Grub安装在mbr,在安装时,会将grub.cfg所在的分区的信息写到mbr中
>> 系统启动时读取mbr,并由mbr中的内容找到grub.cfg, 然后根据grub.cfg中的内容去启动内核等等
>> 只有在mbr中无内容时bios才会去active partition的头部找引导程序
>> Windows在安装时会清除mbr的内容,并将自己的分区设置为active partition, 所以安装windows可能引起linux无法启动
>>
>>
--
Wizard
--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
--
Wizard
在 12-9-4,Zang MingJie<zealo...@gmail.com> 写道:
> 启动流程是:
>
> boot.img (MBR) -> core.img (Hardcode block address)
>
> core.img
> 是一个完整的grub系统,里面包含一个grub.cfg文件,若干个grub模块(根据系统选择不同的模块,比如SATA选择SATA驱动,boot区是ext2选择ext2模块等等)。然后这个core.img会加载自己内置的模块,执行内置的grub.cfg,通常这个grub.cfg会设置grub-root,用于加载硬盘上的其他grub模块,并且加载运行硬盘上的grub.cfg。
>
> 这里分工很明确:
> boot.img:加载core.img
> core.img:加载boot区,以及里面的模块/配置
>
> grub-install干2件事情,生成core.img,生成boot.img并且写入mbr。它不会修改grub.cfg。
>
> On Saturday, September 1, 2012 10:43:04 AM UTC+8, shell909090 wrote:
>>
>> 我看了一下grub的man,事情还是比较清楚的。
>>
>> grub的原始安装路径是/usr/lib/grub/i386-pc。在grub-install的时候,会让你指定一个rootdir,默认是/boot/grub。然后原始路径下的各种mod,img就会往那个目录下装。结束后,grub-install会调用grub-setup,而后者也需要rootdir。grub-setup的目标是让某个设备可引导,即将boot.img安装到mbr或者头分区上。你可以看看grub2的/boot/grub/boot.img,正好512字节。另外,后面还有各种其他方式的引导代码,例如cdboot.img和pxeboot.img。
>>
>> boot.img读取的是core.img还是kernel.img我不知道,反正这步读取是用不着认识文件系统的。然而在stage1.5进入内存后,就需要认识文件系统,然后读取各种mod,还有grub.cfg。理所当然,stage1.5和grub.cfg还有kernel是放在同一个分区上的,这很容易计算出来,stage1.5应当读取哪个分区。
>>
>> 而grub.cfg的读取过程,和自身完全没关系。想也知道,在grub.cfg里面指定自己放哪里是很愚蠢的。我估计这是靠两个值算出来的。首先是stage1.5在哪个分区,也就是所谓的root分区,这很好算。另一个则是你在指定rootdir时指定的目录名,如果没有,则是/boot/grub。我不知道这个是写入boot还是core。不过按照估计,大概是前者的可能性据高。你可以修改一下这个路径,然后grub-install,再读取mbr和core.img,就立刻可以知道是哪个了。
>>
>> 在 2012年9月1日 上午9:39,Wizard <wizard...@gmail.com <javascript:>>写道:
>>> to sh...@googlegroups.com <javascript:>. To unsubscribe from this group,
>>> send email to shlug+un...@googlegroups.com <javascript:>. For more
>>> options, visit this group at
>>> https://groups.google.com/d/forum/shlug?hl=zh-CN
>>>
>>>
>>>
>>
>>
>> --
>> 无能者无所求,饱食而遨游,泛若不系之舟
>> blog: http://shell909090.com/blog/
>> twitter: http://twitter.com/shell909090
>>
>
> --
> -- You received this message because you are subscribed to the Google Groups
> Shanghai Linux User Group group. To post to this group, send email to
> sh...@googlegroups.com. To unsubscribe from this group, send email to
> shlug+un...@googlegroups.com. For more options, visit this group at
> https://groups.google.com/d/forum/shlug?hl=zh-CN
>
>
>
--
Wizard