[syslinux] [PATCH] chain.c32: add menu support to grub loader

Gert Hulselmans gerth at zytor.com
Thu Jul 1 07:03:56 PDT 2010


Paul Bolle wrote:
> On Wed, 2010-06-30 at 16:20 -0700, Gert Hulselmans wrote:
>> Paul Bolle wrote:
>> > Allow the grub loader to (optionally) support using a GRUB menu file.
>> > For example
>> >     chain fs grub=stage2,grub.conf
>> >
>> > will load GRUB's stage2 and pass the (absolute) path to the file
>> > "grub.conf" in the Syslinux filesystem to GRUB's stage2. [...]
>> Why do you add (drivenumber,partition) to the config file name?
>
> In short:  because the patch only allows to use GRUB configuration files
> from the Syslinux filesystem.
>

Why should it be restricted? Doesn't it limit the usefulness of
chainloading stage2?

>> When the user adds the drivenumber and partition to its config filename
>> itself:
>>   chain.c32 hd0,3 grub=/boot/grub/stage2,(hd1,10)/anotherconf.lst
>>
>> you get a "bad" configfilename: (hd0,2)/(hd1,10)/anotherconf.lst
>
> The optional [,<menu>] part is only a filename not a full path. (So is
> the <loader> part, by the way.)
>
>> In my patch, grub will search on the correct drive and partition
>> automatically, when you just use /anotherconf.lst.
>
> Your patch apparently uses paths (for both the stage2 file and the
> configuration file). I thought that (most?) loaders, comparable to the
> stage2 loader, load the files they need from the Syslinux filesystem.

No, most loaders don't care about the partition Syslinux is installed to.
They will read whatever file they want (if they can read that particular
filesystem of course). Syslinux itself is currently restricted to only
being able to read files to load/boot from the partition it is installed
to.

> (I guess that in your patch people may have to mix two different
> syntaxes for drive/partition pairs:
>    the Syslinux syntax: "hd0,3"; and
>    the GRUB syntax: "(hd0,3)".
> It seems better to always use the Syslinux syntax, even for paths to
> GRUB files.)

If they want to load a config file from another partition than the one
specified for stage2, they need to use the GRUB syntax. But I don't think
that it will happen regularly, that you want to load a configfile from
another partition than the one you set as root drive for GRUB.

I think it is better to use GRUB syntax for the "(drive,partition)" part,
if you really want to specify it in your config filename.

>> GRUB just searches its config file on the drive (passed via DL) and
>> partition (install_partition). You don't need to add the right drive and
>> partition to the config filename yourself.
>
> It might not (always) be needed. But it is allowed. GRUB's installer
> seems to do that itself too. So I choose to prefix the path with
> "(drive,partition)" part.

I think it is better to avoid adding "(drive,partition)" to the config
filename. It doesn't seem to be necessary:

  chain.c32 hd1,11 grub=/boot/grub/stage2 grubcfg=/boot/grub/grub.lst
does the same as:
  chain.c32 hd1,11 grub=/boot/grub/stage2 grubcfg=(hd1,10)/boot/grub/grub.lst

Not passing "(drive,partition)" automatically also allows you to load a
config file from another partition than the one which you set as root
partition for GRUB. Just in rare cases you really want that (maybe
recovery situations).

  chain.c32 hd1,11 grub=/boot/grub/stage2 grubcfg=(hd1,8)/boot/grub/grub.lst

This will set the root partition for GRUB to (hd1,10) (GRUB syntax) and
will read the config file from (hd1,8) (GRUB syntax).

I tested it, and it works. I have 2 different /boot/grub/grub.lst files on
(hd1,8) and (hd1,10). When I boot with this command line, it loads the
config on (hd1,8). When I do "configfile /boot/grub/grub:lst", it load the
config file from the root partition (hd1,10) of GRUB, so the root drive is
still correctly set when you read a config file from another partition.

- Gert Hulselmans




More information about the Syslinux mailing list