grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Environment block support for grub2


From: Bean
Subject: Re: [PATCH] Environment block support for grub2
Date: Sat, 31 May 2008 18:54:43 +0800

On Sat, May 31, 2008 at 6:10 PM, Robert Millan <address@hidden> wrote:
>> Different platform use grub_machine_get_envblk to return a pointer to
>> the name=value area of environment block. In main.c, it uses
>> grub_parse_envblk to walk through the list and assign values to
>> variables.
>>
>> I also replace grub_machine_set_prefix with grub_machine_set_root. As
>> it seems strange to compute the prefix in grub_machine_set_prefix, and
>> then split it in grub_set_root_dev to get the root device. Now,
>> grub_machine_set_root set the root directly, and in grub_set_root_dev,
>> it uses root and rdir to generate the prefix.
>
> Note that root and prefix don't necessarily have to point at the same device.
>
> prefix always points at the directory containing GRUB modules etc, and is
> needed at initial stage.  root is used later on by grub.cfg to access our
> payload (I think our current use of root to initialise prefix is gratuitous
> and could better be avoided).
>
> Since for initialising root we don't have any problem, as we can use all
> the fancy stuff grub.cfg allows, unless I missed something I think it's
> better if at this stage we just focus on prefix.
>

The root is assigned in the initialization phraze. Currently, it's
done this way:

machine_machine_init -> calculate root device, then set variable
prefix using root and grub_prefix.

modules initialization

grub_set_root_dev -> Use variable prefix to get the root variable.

Load normal.mod

As you can see, it first create prefix, then split it to find root. At
the end of grub_set_root_dev, prefix and root will point to the same
device. This also make it different to change the root setting in
findroot, which is run in modules initialization stage. We must split
prefix to find the root directory, and use the new root to form a new
prefix. The prefix would later be split again to find root, what a
mess.

The new method:

machine_machine_init -> calculate root device, then set root variable directly.

Load variable in the environment block

modules initialization

findroot

more modules initialization

grub_set_root_dev -> Use variable root to get the root prefix.

Load normal.mod

The end result would be the same, but the new method is cleaner, and
allows overwrite of the root and rdir variable using environment block
and findroot.

>> grub-mkimage will initialize the environment block with one item:
>> rdir=/boot/grub
>>
>> Second, use grub-editenv to set the uuid or label of the root device.
>> For example:
>
> Would it be simpler if grub-mkimage embedded an initialised environment
> block directly?

I think it's better to have a seperate tool to do this. Besides,
grub-editenv can also be used to manage external environment block
file, which is used to load/save persistent variable like default.

-- 
Bean




reply via email to

[Prev in Thread] Current Thread [Next in Thread]