2

I am asking, because fragment of file /boot/grub/grub.cfg looks like

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
    source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
    source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

I don't understood, how this should work, because there is no "source" command in grub2 - see
http://www.gnu.org/software/grub/manual/grub.html

source if the command of /bin/sh shell.
I think, that this fragment should include ${config_directory}/custom.cfg
during the building of /boot/grub/grub.cfg (with grub-mkconfig):

[user@localhost ~]$ cat /etc/grub.d/41_custom 
#!/bin/sh
cat <<EOF
if [ -f  \${config_directory}/custom.cfg ]; then
    source \${config_directory}/custom.cfg
elif [ -z "\${config_directory}" -a -f  \$prefix/custom.cfg ]; then
    source \$prefix/custom.cfg;
fi
EOF

but it doesn't!
it just inserts the text with the "source" command...

2 Answers 2

2

here is the description of mapping from command to modulename.mod
http://blog.fpmurphy.com/2010/06/grub2-modules.html?output=pdf

grep -E "^source" /boot/grub/i386-pc/command.lst
source: configfile

grep -E "^\.:" /boot/grub/i386-pc/command.lst
.: configfile

here is the code of function:
http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/commands/configfile.c#n61

So, "source" is just an undocumented command of grub2

1

The manual for Grub 2.02 on the gnu.org website gives documentation for the "source" command at 16.3.71 in the "Command-line and Menu entry commands" section. So by 25th April 2017 - the date of the current version of the Grub Manual - the source command was documented and I now find it being used in the file /etc/grub.d/41_custom in the current Linux MINT 19 distribution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.