[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Environment block support for grub2
From: |
Bean |
Subject: |
[PATCH] Environment block support for grub2 |
Date: |
Sat, 31 May 2008 04:27:31 +0800 |
Hi,
This patch add environment block support, which can be used to locate
root device using uuid or label.
The environment block occupied the space previously used to store
prefix. The structure is like this:
Magic numbe: "EvbK" (4 bytes)
Length of environment block (2 bytes)
null-ended name=value pairs, ended with an empty string.
The previous prefix is stored in variable rdir.
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.
A new tool grub-editenv is added to manage the environment block, for example:
grub-editenv FILE create
Create a blank environment block file. It's used to store external
environment file.
grub-editenv FILE info
Show the info about location and size of environment block in core.img
or external environment file.
grub-editenv FILE list
List the content of environment block.
grub-editenv FILE edit name=value
Edit the environment block. If no value is specify, name=, it deletes the item.
grub-editenv FILE clear
Remove all variables in the environment block.
And there is a new module findroot.mod. It will scan all partitions
and compare their uuid/label with the uuid and label variable, whose
value can be set in the environment block.
Here is an example:
First, use grub-mkimage to create core.img:
grub-mkimage -o core.img pc ext2 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:
grub-editenv core.img edit uuid=xxx-xxxx
grub-editenv core.img edit label=System
If both uuid and label is specified, uuid will take preference, unless
the fs don't support uuid.
You can also change rdir to change the default root directory, or add
debug=all to show debug message, etc.
--
Bean
envblk.diff
Description: Text Data
- [PATCH] Environment block support for grub2,
Bean <=