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;
### END /etc/grub.d/41_custom ###

I don't understood, how this should work, because there is no "source" command in grub2 - see

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 
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;

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

2 Answers 2


here is the description of mapping from command to modulename.mod

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:

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


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.