2

When I run update-grub2 on my Debian Buster server, instead of creating a grub.cfg it creates a grub.cfg.new, even though grub.cfg does not exist.

And because of this my machine boots into a broken grub, because it cannot find grub.cfg.

Is there a way to tell update-grub2 to create grub.cfg instead of grub.cfg.new.

Hunter.S.Thompson
  • 8,839
  • 7
  • 26
  • 41
  • The .new is created whenever you have a typo in any of the grub files used to create grub.cfg. I once forgot a closing } in 40_custom. It then showed error as last line which did not help much, but it may show error line. Also could be in /etc/default/grub, if line not correct. – oldfred Nov 30 '19 at 17:34

2 Answers2

2

You can use grub-mkconfig -o /boot/grub2/grub.cfg instead.

Hunter.S.Thompson
  • 8,839
  • 7
  • 26
  • 41
Timur.C
  • 51
  • 2
  • I gave this a try earlier, instead of me running this command Ansible ran it and it created the same .new extension, but when I ran it normally, it created `grub.cfg`. At least according to the question, this answer is right, I am gonna accept it. – Hunter.S.Thompson Nov 30 '19 at 13:51
0

I ran grub-mkconfig -o /boot/grub/grub.cfg using Ansible, it created the same .new extention.

But when I used grub-mkconfig > /boot/grub/grub.cfg, it ran successfully and created grub.cfg.

-o might not be the same as >.

Looking at the source code after @oldfred 's comment, found out that the .new extension is created when there is an error in either /etc/default/grub or /etc/grub.d/* files. See here:

if test "x${grub_cfg}" != "x" ; then
  if ! ${grub_script_check} ${grub_cfg}.new; then
    # TRANSLATORS: %s is replaced by filename
    gettext_printf "Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
%s file attached." "${grub_cfg}.new" >&2
    echo >&2
    exit 1
  else
    # none of the children aborted with error, install the new grub.cfg
    mv -f ${grub_cfg}.new ${grub_cfg}
  fi
fi
Hunter.S.Thompson
  • 8,839
  • 7
  • 26
  • 41