update-grub does not update /boot/efi/EFI/ubuntu/grub.cfg

16,265

Solution 1

root cause: user error.

I accidentally copied /boot/grub/grub.cfg to /boot/efi/EFI/ubuntu/grub.cfg while trying to debug some grub settings didn't take effect. From that point on behaviour was non-standard on my system.

thanks to oldfred for helping me realise the original /boot/efi/EFI/ubuntu/grub.cfg had just been a three lines file referring /boot/grub.cfg.

Solution 2

Just to close the loop on this query - I needed updates to /boot/efi/EFI/ubuntu/grub.cfg because I had changed the location of my /boot directory (UUID changed). update-grub doesn't update that file, but

sudo dpkg-reconfigure grub-efi-amd64

will trigger a re-write, after you have answered some questions.

Solution 3

I ran into this as well. To update your EFI grub.cfg, you want to do:

grub-install --efi-directory=/boot/efi

If your EFI is mounted at /boot/efi.

Solution 4

blaufish notes that

the original /boot/efi/EFI/ubuntu/grub.cfg had just been a three lines file referring /boot/grub.cfg.

This three line grub.cfg is not used, at least on my grub 2.02-2ubuntu8.6 with btrfs. The 2nd line reads

set prefix=($root)'/@/boot/grub'

There is now no @ on $root, and there wasn't when grub-install was run. (@ was a zesty install that became corrupt, and deleted some time ago.) Instead, the grub path to grub.cfg is written into the grubx64.efi executable. One might see what this is by running

strings grubx64.efi | tail

I mention this because somebody might imagine, as I did once, that changing this grub.cfg to point somewhere else would be useful. I use the --boot-directory option to grub-install to set this. I have the btrfs root mounted (subvolid=5,subvol=/) at /mnt/top, and want to boot to /@grub:

--boot-directory=/mnt/top/@grub/boot

(I'm not sure this has always worked. When I first tried to set up grub independently of any install on btrfs, I had trouble, and ended up using a snapshot that I could boot from to make grub-install write what I wanted. But it's good now.)

Share:
16,265

Related videos on Youtube

blaufish
Author by

blaufish

Updated on September 18, 2022

Comments

  • blaufish
    blaufish over 1 year

    (EDIT 3: User error. Copied over /boot/efi/EFI/ubuntu/grub.cfg while debugging a boot problem)

    After installing recently released Ubuntu 18.04 Server in UEFI Secure Boot mode the installer has put grub.cfg in this location:

    • /boot/efi/EFI/ubuntu/grub.cfg

    This matches the tables created when selecting Filesystem: manual partition, which mounts the boot partion at /boot/efi (/dev/sda1).

    However, sudo update-grub and sudo update-grub2 does not overwrite the grub configuration, instead updating /boot/grub/grub.cfg, i.e. a file not on the boot partition.

    Question 1: Has update-grub, update-grub2 etc been superseded by some new procedure? Question 2: If not, is this a bug to be filed?

    EDIT: Confused++.

    • Computer 1, actual hardware, manual portioning in installation and minor updates, e.g. sudo apt install tboot, problem can be reproduced.

    • Computer 2, vmware image: vanilla install, problem cannot be reproduced.

    Both computers are UEFI Secure Boot and have same/similar partioning. the different grub.cfg experience the same update behaviour, but on the vmware image, grub respects the file /boot/grub/grub.cfg, on hardware install grub respects the /boot/efi/EFI/ubuntu/grub.cfg.

    EDIT 2:

    • Computer 1 has now been re-installed both with manual filesystem portioning and then again with the original partitioning (250GB disk, 120GB used, rest left free). Neither re-install could reproduce the original problem, so basically now the problem is gone. All three installations on the computer was from the same ISO / USB stick.
    • oldfred
      oldfred about 6 years
      The sudo update-grub only updates the grub.cfg in /boot whether partition or folder inside / (root). But with UEFI there is another grub.cfg inside the /boot/efi/EFI/ubuntu folder. It is just 3 lines and is a configfile entry to find the full grub.cfg in your install. I have multiple Ubuntu installs, and each new install overwrites the ESP and my main working grub.cfg. I learned to back up ESP, particularly the grub.cfg to restore main working install as default boot.
    • blaufish
      blaufish about 6 years
      thanks oldfred. explanation was very simple: user error. I copied over /boot/efi/EFI/ubuntu/grub.cfg while trying to debug why some settings didn't take effect, and from that point on behaviour was non-standard on my system.
  • CoderGuy123
    CoderGuy123 about 3 years
    This app was missing on Mint 20 (Ubuntu 20.04 base).
  • CoderGuy123
    CoderGuy123 about 3 years
    Worked for me on Mint 20 (Ubuntu 20.04) but have to use sudo otherwise get misleading errors.