19

When running sudo apt upgrade on Ubuntu 20.04.1 I always receive the following error:

Setting up grub-efi-amd64-signed (1.142.6+2.04-1ubuntu26.4) ...
mount: /var/lib/grub/esp: special device /dev/disk/by-id/ata-Samsung_SSD_860_EVO
_500GB_S3Z1NB0K866259H-part1 does not exist.
dpkg: error processing package grub-efi-amd64-signed (--configure):
 installed grub-efi-amd64-signed package post-installation script subprocess ret
urned error exit status 32
dpkg: dependency problems prevent processing triggers for shim-signed:
 shim-signed depends on grub-efi-amd64-signed | grub-efi-arm64-signed; however:
  Package grub-efi-amd64-signed is not configured yet.
  Package grub-efi-arm64-signed is not installed.

dpkg: error processing package shim-signed (--configure): dependency problems - leaving triggers unprocessed Errors were encountered while processing: grub-efi-amd64-signed shim-signed

I would like some way to fix the package installation, so apt upgrade works without errors.

The context for this error: I bought a new SSD, connected it to my computer, dd'd the contents of ata-Samsung_SSD_860_EVO_500GB_S3Z1NB0K866259H onto the new disk, edited /etc/fstab to point to the new disk, rebooted, updated the BIOS and started using Ubuntu on the new disk.

Everything has been functioning fine (booting into Ubuntu, using software and hardware, upgrading other packages), except for this one error above, where the grub package upgrade process is trying to find the old drive.

Things I have tried:

  1. sudo dpkg --configure -a just in case it would magically fix the issue
  2. sudo dpkg-reconfigure grub-efi-amd64-signed but that just returns 'grub-efi-amd64-signed is broken or not fully installed.'
  3. grepping the whole of /etc/ and /boot/ for any reference to the old disk, there aren't any

4 Answers4

17

I just have had same problem. Thanks to your answer I knew what to do, but I suggest solution w/o using GParted GUI.

sudo parted
(parted) p
Model: ATA WDC WDS500G2B0A (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags 1 1049kB 538MB 537MB fat32 boot 2 538MB 500GB 500GB ext4 (parted) set 1 esp on (parted) p Model: ATA WDC WDS500G2B0A (scsi) Disk /dev/sda: 500GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags:

Number Start End Size File system Name Flags 1 1049kB 538MB 537MB fat32 boot, esp 2 538MB 500GB 500GB ext4

Now the flag is set. After that:

sudo apt --fix-broken install

And now grub-efi-amd64-signed installs correctly and after reboot everything is working fine.

gofr1
  • 271
10

The problem was the /boot/efi partition lacked the esp flag, so grub couldn't determine where to put its EFI files.

The solution was to open gparted, right-click Manage flags on the /boot/efi partition, click the esp tickbox, then Close.

Then running sudo apt upgrade asked a question during configuration of the grub-efi-amd64-signed package asking which disk grub should be installed to:

The GRUB boot loader was previously installed to a disk that is no longer present, or whose unique identifier has changed for some reason.

Since the esp flag is set in gparted the question dialog allowed ticking the box for the new disk, I did so, pressed Enter and the package upgraded successfully.

right-click menu, manage flags highlighted, in gparted

8

I had the same problem on AWS EC2 instance restored from AMI. I solved it by:

sudo rm /var/cache/debconf/config.dat

After this I was able to run sudo dpkg --configure -a without problems

Dima L.
  • 1,903
  • 15
  • 11
3

We had a ~100 freshly imaged machines displaying this error so we wanted a quick scriptable solution.

Quick Fix:

Run the following as root

echo PURGE | debconf-communicate grub-common
echo PURGE | debconf-communicate grub-pc
dpkg --configure -a

Alternate Error Message - As well as the error given in the question we also saw the following message which I will post for completeness:

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.

Bastion
  • 191