2

Q1. Wanted to know how do you read the contents of a file to a variable at boot time in grub.cfg?

Q2. Could that be extended to read an .ini type file where you can read the values for various name entries?

[section] nothisone=whatever thisone=this is what I want to get

TIA!!

user3161924
  • 1,849
  • 18
  • 33

2 Answers2

4

In order to do exactly what you are asking for, you would probably need to write your own GRUB module.

However, you should be able to achieve what you're after either using the configfile command, or with some clever application of the environment block feature.

unixsmurf
  • 5,852
  • 1
  • 33
  • 40
1

Use "source" command to include another config file but unlike "configfile" which will change context. Source is like an online macro while configfile likes a function - environment changes in configfile will not be preserved but source is expanding whatever in the source file and put in the main block, environment variable can be changed in this way.

https://www.gnu.org/software/grub/manual/grub/grub.html#source https://www.gnu.org/software/grub/manual/grub/grub.html#configfile

Michael
  • 61
  • 4