[syslinux] [PATCH] chain.c32: add support for loading GRUB stage2

Paul Bolle pebolle at tiscali.nl
Fri Jun 18 05:22:15 PDT 2010


On Tue, 2010-06-08 at 15:38 -0700, H. Peter Anvin wrote:
> On 06/08/2010 03:30 PM, Thomas Bächler wrote:
> > Am 09.06.2010 00:13, schrieb H. Peter Anvin:
> >>>> Without menu.lst, grub will just show a prompt. If I am right, it would
> >>>> be very useful to be able to APPEND a "root" so that a chainloaded grub
> >>>> can load a configuration file without user intervention.
> >>>
> >>> GRUB's stage2 doesn't have a command line itself, does it? That implies
> >>> APPEND is not the most obvious way to supply GRUB's stage2 with
> >>> additional parameters.
> >>>
> >>
> >> No, the right way is to pass in the disk coordinates via the Multiboot
> >> field.  It requires partition-scanning code in mboot.c32 which I so far
> >> have avoided putting in, but I guess it's time.
> > 
> > We are talking about 2 different things here:
> > 
> > 1) Paul was talking about the chain.c32 code to load grub-legacy's
> > stage2 (grub-legacy is not a multiboot image).
> > 2) You are talking about mboot.c32, which one can use to load grub2.
> > 
> > In case 1), there is no multiboot field. 
> 
> Yes, but I think grub-legacy has some internal way to pass the same
> information in the same format... the format is a Grubism, after all...
> makes sense to Grub and Grub alone...

0) Some thoughts (also written to aid my memory, because I'm bound to
forget details like these - it's hard enough to remember this stuff
after just two weeks).

1) The code in stage2/asm.S seems to hold all (or most?) information
available for GRUB's stage2 (which can be found at 0x820:0x0 and up once
stage2 is loaded).

2) For this discussion install_partition and config_file are the most
relevant. 

3)install_partition somehow stores a value for GRUB's "root" (but I
haven't yet figured out how it does that, so the current code is hard
coded to use a value meaning "(hd0)" in GRUB's syntax).

4) config_file might be interesting. It allows to store a string with
the path of GRUB's configuration file (eg, "(hd0,1)/menu.lst", at
0x820:0x17, with a maximum length of 89 bytes). So, if chain.c32 knows
about the disk and partition it is reading its files from (and it is
possible to reliably translate that information to GRUB's syntax) it
might be an idea to add another option to chain.c32. Say, something
like:
    menu=foo
which would set the config_file string (in the copy of stage2 in memory)
with a valid GRUB path to the file "foo" in the syslinux file system.

Would that be feasible?


Paul





More information about the Syslinux mailing list