grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Save/Load environment variable support


From: Bean
Subject: Re: [PATCH] Save/Load environment variable support
Date: Fri, 4 Jul 2008 05:06:31 +0800

On Fri, Jul 4, 2008 at 4:41 AM, Marco Gerards <address@hidden> wrote:
> Pavel Roskin <address@hidden> writes:
>
>> On Thu, 2008-07-03 at 20:04 +0200, Marco Gerards wrote:
>>
>>> Great!  Can you explain how it works?
>>
>> Very good question.  It's not "discoverable".  I could not find way to
>> figure out that /boot/grub/grubenv is the default without looking at the
>> code.
>
> Actually, I meant how it works technically.

Hi,

It first reads the first 8192 bytes into memory, then, set read_hook
and do it again. Inside the hook, it records the sector location. It
then uses the location list to read from disk, and compare the result.
If they match, we assume it's the right one.

There are some consideration about the environment file. First, it
must be at least 8192 bytes long, this is used to avoid tail packing
in some fs. Then, we have the signature "GeNv", followed by the length
of the block. The signature doesn't need to the at the beginning, but
it has to been within the first 8192 byte, and dword aligned. This is
used to simplify the search function, also reduce the change of a
mismatch. The environment block consists of name=value strings,
terminated by an empty string.

The environment block can be embedded in other files, like core.img.
Then we can use grub-editenv, or save_env from grub console, to set
variable which can be used to locate root at runtime, like uuid, etc.
But this is the subject of another patch.

-- 
Bean




reply via email to

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