You are not logged in.
Pages: 1
I'm trying to get a clear mental image of this in my head: Grub has two stages, stage1 and stage2. stage1 gets written to the MBR. stage2 gets written to... anywhere special, other than simply the file /boot/grub? Since it appears to me that stage1 is the same for all Grub installs, how does it know which partition to look on for stage2?
This question arises because I have two installs of Grub on two different partitions, and reinstalling Grub under the distro on each partition makes its own Grub the default one on boot. But since their stage1's are identical, I'm wondering what is changing between installing Grub to one partition and installing it to the other partition that tells the MBR to point to the different GRUBs.
(Part of the reason I ask is to see if there's an easier/lazier way to switch between the GRUB installs without re-installing GRUB. My initial thought was to back-up and restor the MBR, but that doesn't look like it will work.)
Offline
You tell it where to look with
root (hd0,0) <== this one
setup (hd0)
It seeks in that partition under / and /grub
Last edited by klixon (2008-11-16 08:06:19)
Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!
Offline
It seeks in that partition under / and /grub
Do you mean, it seeks in that partitition for /grub or /boot/grub?
Offline
The option --prefix specifies the directory under which GRUB images are put. If it is not specified, GRUB automatically searches them in /boot/grub and /grub.
indeed.. good catch
Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!
Offline
...reason I ask is to see if there's an easier/lazier way to switch between the GRUB installs without re-installing GRUB.
Also I prefer to be lazy and let the kernel package's install scripts update all /boot/grub/menu.lst's... I have 3 Linux installations and just 1 hdd in one box. Every installation has it's own /boot partition with it's own grub binaries.
sda1 = 1st installations /boot partition, 100 MB ( grub installed to /dev/sda's main MBR )
sda2 = 2nd installations /boot partition, 100 MB ( grub installed to /dev/sda2 )
sda3 = 3rd installations /boot partition, 100 MB ( grub installed to /dev/sda3 )
Everything I had to manually was
1) for chain booting other grubs I added
title 2nd Linux
rootnoverify (hd0,1)
chainloader +1
title 3rd Linux
rootnoverify (hd0,2)
chainloader +1
in the the very first /boot/grub/menu.lst (at /dev/sda1)
2) be awake when configuring 2nd & 3rd installations so that their grubs are installed on sda2 and sda3, not sda's MBR.
With newer hardware it may be possible to skip separate /boot partitions, but actually they can be practical. My SCSI card's firmware says at boot up (c) 1994, so it couldn't boot over 2 GB...
Last edited by grep (2008-11-16 18:34:48)
Offline
You tell it where to look with
root (hd0,0) <== this one setup (hd0)
It seeks in that partition under / and /grub
But when Grub is loading, how does it know what was specified? Once Grub has loaded stage1 from the disk's MBR that's all it has to work with, it has no access to any other configuration data until stage2 is loaded, which is why I wonder how stage2 is loaded. So I can only presume that this information is written into stage1 in the MBR.
Last edited by B-Con (2008-11-22 07:41:15)
Offline
I think stage one includes some basic information so that it can read whatever filesystem stage 2 is located on, and from stage two it can load all the info it needs to read it's config, kernels, etc.
I might be wrong.
Offline
I think stage one includes some basic information so that it can read whatever filesystem stage 2 is located on, and from stage two it can load all the info it needs to read it's config, kernels, etc.
I might be wrong.
stage1 is only 448 bytes, though, and while I suppose it's possible that it could read the basics of a filesystem with just that much code, I find it hard to believe that it could read every possible supported filesystem. stage1 would then have to be customized to the specific FS of the target destination.
Offline
You are missing stage 1.5 which is started by stage1 and which knows how to read the filesystem. See http://www.pixelbeat.org/docs/disk/ for example.
Offline
I'm trying to get a clear mental image of this in my head: Grub has two stages, stage1 and stage2. stage1 gets written to the MBR. stage2 gets written to... anywhere special, other than simply the file /boot/grub? Since it appears to me that stage1 is the same for all Grub installs, how does it know which partition to look on for stage2?
hi, i have the same question, and a quick google search give me some info: http://ubuntuforums.org/showthread.php?t=825734
hope it's useful for you.
Offline
You are missing stage 1.5 which is started by stage1 and which knows how to read the filesystem. See http://www.pixelbeat.org/docs/disk/ for example.
B-Con wrote:I'm trying to get a clear mental image of this in my head: Grub has two stages, stage1 and stage2. stage1 gets written to the MBR. stage2 gets written to... anywhere special, other than simply the file /boot/grub? Since it appears to me that stage1 is the same for all Grub installs, how does it know which partition to look on for stage2?
hi, i have the same question, and a quick google search give me some info: http://ubuntuforums.org/showthread.php?t=825734
hope it's useful for you.
Nice, thanks for the links, very helpful.
Also I prefer to be lazy and let the kernel package's install scripts update all /boot/grub/menu.lst's... I have 3 Linux installations and just 1 hdd in one box. Every installation has it's own /boot partition with it's own grub binaries.
Thanks for the tip, that'll be helpful.
Offline
Pages: 1