11

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/.

Melebius
  • 11,800
  • 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

3 Answers3

1

This question is old but I got stuck into it passing from Ubuntu 22.04 to Ubuntu 24.04.

From Ubuntu 22.04

Before launching do-release-upgrade, my file /var/cache/debconf/config.dat shows this

Name: grub-pc/install_devices
Template: grub-pc/install_devices
Value: /dev/sda
Owners: grub-pc
Flags: seen

I changed /dev/sda to /dev/vda, then run do-release-upgrade with all the non-interactive options and it got through all the upgrade by itself.

From Ubuntu 24.04

If you have launched the do-release-upgrade and are already stuck with the error

│ The GRUB boot loader was previously installed to a disk that is no longer present, or whose unique identifier has
│ image stays in sync with GRUB modules and grub.cfg. Please check again to make sure that GRUB is written to the ap
│ If you're unsure which drive is designated as boot drive by your BIOS, it is often a good idea to install GRUB to
│
│ Note: it is possible to install GRUB to partition boot records as well, and some appropriate partitions are offere
│ less reliable, and therefore is not recommended.
│ GRUB install devices:
│  [ ] /dev/vda3 (26303 MB;
│  [ ] /dev/vda (26843 MB; ???)
│  [ ] /dev/dm-0 (12884 MB; snb-root)
│  [ ] /dev/vda2 (536 MB; ???)

And you want to pass through it without interaction:

  • Edit /var/cache/debconf/config.dat, changing /dev/sda to /dev/vda in relevant sections
  • Re-run command apt-get upgrade which should work without asking asking anything.
Rémi.B
  • 111
  • Not sure if editing /var/cache/debconf/config.dat manually is really the best thing to do. See also my answer here: https://askubuntu.com/a/1549473/18045 – Melroy van den Berg May 27 '25 at 13:28
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
  • 33
-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