Some Bits: Nelson's log

Ubuntu 23.10 upgraded: signed GRUB failed

Tried upgrading my main daily driver Ubuntu system from 23.04 to 23.10 and got left with a broken system. Upgrading grub-efi-amd64-signed failed with the error Unknown device "/dev/disk/by-id/*": No such device. I tried hacking around to get it working and failed. Finally reloaded from the Proxmox VM backup I’d thankfully made before trying the upgrade. I filed an Ubuntu bug.

I’m totally guessing here but I think the underlying cause is from when I virtualized the Linux server from physical hardware to a VM. That worked, including Secure Boot and ordinary kernel updates and update-grub, but now upgrading the GRUB packages fails. On the virtual system there really is no /dev/disk/by-id filesystem right now after rebooting back to 23.04. This discussion says that’s working as intended, that virtio devices don’t have serial numbers. I assume my old physical server had entries in /dev/disk/by-id. Those old entries are referenced in the hard-to-find /var/cache/debconf file, which contains the actual configuration options chosen at apt install time. And so now when I go to update the grub package it picks up the old config which is no longer valid.

If my diagnosis is right the fix is to get the working GRUB install to reconfigure itself somehow to use whatever new path is relevant, to stop referencing /dev/disk/by-id. And only then attempt an Ubuntu release upgrade.

Update: I tried just running dpkg-reconfigure grub-efi-amd64-signed. That just prints the error about /dev/disk/by-id missing. That seems like a usability bug; the reconfigure tool should recover gracefully if the configuration is bad. I tried various other methods of convincing apt to reconfigure GRUB but the best I could do was change the menu entries or Linux command line, never change which device it thought GRUB should be installed on.

Update 2: I may have found a fix using debconf-set-selections to reconfigure GRUB. It sort of worked but not entirely.

It’d be awfully nice if the package installer had better error messaging and recovery.

Detailed notes

Some extra details that are poorly edited but I’m capturing anyway.

Looking around on the Internet I found lots of posts about upgrades failing on this package going back to Ubuntu 18.04. Lots of various cargo cult solutions. This one is clearer than most. See also here or here. All of them boil down to forcing apt to remove and reinstall GRUB.

Here’s what I did in my failed attempt to reinstall GRUB after the upgrade had failed.

apt remove --allow-remove-essential grub-efi-amd64-signed shim-signed
apt install grub-efi
update-grub

This succeeded in that it installed a new, unsigned GRUB. But the Proxmox OVMF BIOS refused to boot it. The BIOS had secure boot turned on; turning that off it still refused to boot. Probably what I really should have done was force a proper reconfigure of the signed GRUB install instead. I tried to do that but various methods of reinstalling grub-efi-amd64-signed kept failing on the missing /dev/disk/by-id/. Need to look up how to force a full reconfigure of that package.

Boy do I hate messing with GRUB.

Dump of error logs:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up grub-efi-amd64-signed (1.197+2.12~rc1-10ubuntu4) ...
Unknown device "/dev/disk/by-id/*": No such device
dpkg: error processing package grub-efi-amd64-signed (--configure):
installed grub-efi-amd64-signed package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of shim-signed:
shim-signed depends on grub-efi-amd64-signed (>= 1.191~) | grub-efi-arm64-signed (>= 1.191~) | base-files (<< 12.3); however:
Package grub-efi-amd64-signed is not configured yet.
Package grub-efi-arm64-signed is not installed.
Version of base-files on system is 13ubuntu2.1.
shim-signed depends on grub-efi-amd64-signed (>= 1.187.2~) | grub-efi-arm64-signed (>= 1.187.2~); 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 unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
grub-efi-amd64-signed
shim-signed
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

Here’s the entries in /var/cache/debconf that reference the missing path

Name: grub-efi/install_devices

Template: grub-efi/install_devices
Value: /dev/disk/by-id/nvme-eui.002538b22140b542-part1
Owners: grub-common, grub-efi-amd64, grub-pc
Flags: seen
Variables:
CHOICES = /dev/nvme0n1p1 (1127 MB; /boot/efi) on 2000398 MB Samsung SSD 980 PRO with Heatsink 2TB
RAW_CHOICES = /dev/disk/by-id/nvme-eui.002538b22140b542-part1

Name: grub-pc/install_devices
Template: grub-pc/install_devices
Value: /dev/disk/by-id/nvme-Samsung_SSD_980_PRO_with_Heatsink_2TB_S6WRNS0T220037X
Owners: grub-pc
Flags: seen

This might be the original install log that shows what path was chosen. If so, it gives a choice for an alternate name for the device.

2022-08-09 23:28:45,261 - cc_grub_dpkg.py[DEBUG]: considering these device symlinks: /dev/disk/by-id/nvme-Samsung_SSD_980_PRO_with_Heatsink_2TB_S6WRNS0T220037X,/dev/disk/by-id/nvme-eui.002538b22140b542,/dev/disk/by-path/pci-0000:01:00.0-nvme-1

2022-08-09 23:28:45,261 - cc_grub_dpkg.py[DEBUG]: filtered to these disk/by-id symlinks: /dev/disk/by-id/nvme-Samsung_SSD_980_PRO_with_Heatsink_2TB_S6WRNS0T220037X,/dev/disk/by-id/nvme-eui.002538b22140b542
2022-08-09 23:28:45,261 - cc_grub_dpkg.py[DEBUG]: selected /dev/disk/by-id/nvme-Samsung_SSD_980_PRO_with_Heatsink_2TB_S6WRNS0T220037X

More info on how debian is configured

# debconf-get-selections | grep dev/disk
grub-common grub-efi/install_devices multiselect /dev/disk/by-id/nvme-eui.002538b22140b542-part1
grub-efi-amd64 grub-efi/install_devices multiselect /dev/disk/by-id/nvme-eui.002538b22140b542-part1
grub-pc grub-efi/install_devices multiselect /dev/disk/by-id/nvme-eui.002538b22140b542-part1
grub-common grub-efi/install_devices_disks_changed multiselect /dev/disk/by-id/nvme-eui.002538b22140b542-part1, /dev/vda1
grub-efi-amd64 grub-efi/install_devices_disks_changed multiselect /dev/disk/by-id/nvme-eui.002538b22140b542-part1, /dev/vda1
grub-pc grub-pc/install_devices string /dev/disk/by-id/nvme-Samsung_SSD_980_PRO_with_Heatsink_2TB_S6WRNS0T220037X