user2679024
user2679024

Reputation: 73

Using grub, is it possible to use "if, while" during booting (before loading normal.mod)?

My computer has grub installed. During booting before normal.mod is loaded, I need to be able to run if and while commands in my config file which has been linked into core.img (using grub-mkimage -c myconfig.confg). In myconfig.config, I have an if statement and I kept getting "unknown command if" during booting. I saw an example in http://www.gnu.org/software/grub/manual/html_node/Embedded-configuration.html and looks like I just need to include search, test, and normal modules. Am I missing something? Thanks

Upvotes: 7

Views: 1296

Answers (1)

xchange
xchange

Reputation: 485

Not sure whether this is a bug or the documentation is lacking information.

Anyway there is a workaround by putting your config file in a memdisk image which you can append to the core.img. The config file can then be executed - including scripting support - via configfile:

Create a tarball formatted memdisk image including your config file:

tar -cf memdisk.tar myconfig.config

Create early.cfg: (which will serve to execute myconfig.config via configfile):

configfile (memdisk)/myconfig.config

Create core.img: (note that you will need the additional modules memdisk tar configfile)

grub-mkimage -c early.cfg -m memdisk.tar -o core.img search test normal memdisk tar configfile

Upvotes: 4

Related Questions