Error upgrading grub-efi-amd64-signed - special device [old SSD] does not exist

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

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.


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