8

I have an Ubuntu 16.04 virtual machine (local, no cloud) which was created as a clone of another computer. Each time GRUB packages are upgraded using apt upgrade, I get the following message:1

The GRUB boot loader was previously installed to a disk that is no longer present, or whose unique identifier has changed for some reason. It is important to make sure that the installed GRUB core image stays in sync with GRUB modules and grub.cfg. Please check again to make sure that GRUB is written to the appropriate boot devices.

and then it asks to select an install device.

I am able to finish the GRUB upgrade successfully but the message appears again during the next GRUB upgrade, although the disk is not altered between the upgrades.

How can I “reset” the GRUB configuration to the current one, so it does not ask again?

Examined similar questions

I am not trying to silence upgrade messages as similar questions (https://serverfault.com/questions/662624/how-to-avoid-grub-errors-after-runing-apt-get-upgrade-ubunut, How do I apt-get -y dist-upgrade without a grub config prompt?) suggest. I want to overcome this particular question regarding GRUB upgrade.

The commands from the most upvoted answer to a similar question on ServerFault cannot be applied in my case, I don’t have the mentioned files /boot/grub/menu.lst and update-grub-legacy-ec2 on my machine.

My configuration

I tried to run the commands suggested by oldfred:

$ sudo debconf-show grub-pc
  grub-pc/install_devices_failed_upgrade: true
  grub-pc/mixed_legacy_and_grub2: true
  grub-pc/install_devices_failed: false
  grub-pc/hidden_timeout: false
  grub2/update_nvram: true
  grub-pc/timeout: 5
  grub-pc/install_devices_empty: false
* grub-pc/install_devices_disks_changed: /dev/disk/by-id/ata-VBOX_HARDDISK_VBd7a628c1-923a4727
  grub2/kfreebsd_cmdline:
* grub2/linux_cmdline: consoleblank=0
  grub2/kfreebsd_cmdline_default: quiet splash
  grub-pc/disk_description:
  grub-pc/postrm_purge_boot_grub: false
  grub-pc/partition_description:
* grub-pc/install_devices: /dev/disk/by-id/ata-VBOX_HARDDISK_VBd7a628c1-923a4727
  grub-pc/chainload_from_menu.lst: true
  grub2/force_efi_extra_removable: false
  grub-pc/kopt_extracted: false
* grub2/linux_cmdline_default:
  grub2/device_map_regenerated:

seems to match

$ sudo lshw -C Disk | grep serial
       serial: VBd7a628c1-923a4727

but grub-probe -t device /boot/grub returns the name of the root device of the clone’s master. I tried the suggested command sudo dpkg-reconfigure grub-pc but it did not update the output of sudo grub-probe -t device /boot/grub. How to fix this?


1 I get the message in a localized version, the pasted English version is copied from https://samrueby.com/2014/09/02/updating-grub-in-ubuntu-amazon-ec2-instance/.

Organic Marble
  • 23,641
  • 15
  • 70
  • 122
Melebius
  • 11,431
  • 9
  • 52
  • 78
  • https://serverfault.com/questions/662624/how-to-avoid-grub-errors-after-runing-apt-get-upgrade-ubunut – Liso Apr 16 '19 at 12:10
  • @Emmet Thank you for your reaction. I don’t find this applicable in my case, see the update to my question. – Melebius Apr 16 '19 at 12:39
  • 2
    Grub remembers where to install in BIOS boot mode: https://askubuntu.com/questions/458572/how-do-i-prevent-one-of-my-partitions-messing-with-lubuntu-grub-entries/458582#458582 compare to your drives as listed: sudo lshw -C Disk -short – oldfred Apr 16 '19 at 14:07
  • 1
    @oldfred This seems to be the right direction. grub-probe -t device /boot/grub keeps showing the outdated value and dpkg-reconfigure grub-pc does not fix that. How can I proceed? – Melebius Apr 17 '19 at 07:45
  • Are you choosing a new drive like sda for new location of grub. You have to use tab & enter to change settings. Otherwise try a full reinstall of grub, not just update-grub. You can manually do it or use Boot-Repair's advanced options, choose install & drive. https://help.ubuntu.com/community/Boot-Repair – oldfred Apr 17 '19 at 12:28

2 Answers2

0

If I were you, I would completely reinstall grub, checking UUIDs of disks. But you should do this OUTSIDE of your linux instance, i.e. running a live distro on a USB key and then mounting your partitions on the live filesystem and THEN reinstalling GRUB.

Have a look here: https://help.ubuntu.com/community/Grub2/Installing

Pasha
  • 23
-1

I got the same error message on my system running Ubuntu 20.04.1. In my case /boot/efi is on its own partition. The following procedure solved the problem: Before apt-get update unmount /boot/efi.

umount /boot/efi
apt-get upgrade
mount /boot/efi
rho
  • 1