从 Ubuntu 16.04 升级到 Ubuntu 18.04 后无法更新任何软件包

从 Ubuntu 16.04 升级到 Ubuntu 18.04 后无法更新任何软件包

昨天我将操作系统从 16.04 升级到了 18.04。升级 6 个软件包(即grub-efi-amd64, gdm3, grub-efi-amd64-signed, cups-pk-helper, ubuntu-desktop, gnome-initial-setup)时安装失败,但进程显示升级将继续。因此我假设重启后可以更新它们。此后系统重启正常,但每当我尝试安装任何新软件包时,我都会收到以下错误消息。

(base) user@L-156108409-HP-ProBook-440-G4:~$ sudo dpkg --configure -a
[sudo] password for user: 
Setting up grub-efi-amd64 (2.02-2ubuntu8.15) ...
od: /sys/firmware/efi/efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c: Operation not permitted
/usr/share/grub/grub-check-signatures: 22: [: Illegal number: 
dpkg: error processing package grub-efi-amd64 (--configure):
 installed grub-efi-amd64 package post-installation script subprocess returned error exit status 255
Setting up gdm3 (3.28.3-0ubuntu18.04.4) ...
chage: /etc/passwd.7558: Permission denied
chage: cannot lock /etc/passwd; try again later.
Stopped: `/usr/bin/chage -M 99999 gdm' returned error code 1. Exiting.

Removing user `gdm' ...
dpkg: error processing package gdm3 (--configure):
 installed gdm3 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of grub-efi-amd64-signed:
 grub-efi-amd64-signed depends on grub-efi-amd64 | grub-pc; however:
  Package grub-efi-amd64 is not configured yet.
  Package grub-pc is not installed.

dpkg: error processing package grub-efi-amd64-signed (--configure):
 dependency problems - leaving unconfigured
Setting up cups-pk-helper (0.2.6-1ubuntu1.2) ...
chage: /etc/passwd.7581: Permission denied
chage: cannot lock /etc/passwd; try again later.
Stopped: `/usr/bin/chage -M 99999 cups-pk-helper' returned error code 1. Exiting.

Removing user `cups-pk-helper' ...
dpkg: error processing package cups-pk-helper (--configure):
 installed cups-pk-helper package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of ubuntu-desktop:
 ubuntu-desktop depends on gdm3; however:
  Package gdm3 is not configured yet.

dpkg: error processing package ubuntu-desktop (--configure):
 dependency problems - leaving unconfigured
Setting up gnome-initial-setup (3.28.0-2ubuntu6.16.04.6) ...
chage: /etc/passwd.7601: Permission denied
chage: cannot lock /etc/passwd; try again later.
Stopped: `/usr/bin/chage -M 99999 gnome-initial-setup' returned error code 1. Exiting.

Removing user `gnome-initial-setup' ...
dpkg: error processing package gnome-initial-setup (--configure):
 installed gnome-initial-setup package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 grub-efi-amd64
 gdm3
 grub-efi-amd64-signed
 cups-pk-helper
 ubuntu-desktop
 gnome-initial-setup

我意识到这是因为这 6 个损坏的包裹,并且我尝试了提到的解决方案这里这里这里(安装了 mokutil,但没什么区别)。我也尝试过单独重新安装这些包,但没有成功。另一个解决方案提到这里建议我从 dpkg 中的状态文件中删除这些包,但由于其中两个与 grub 相关,所以我不想再处理这个问题。

有人能帮我解决这些问题吗?提前谢谢了。

編輯:這個关联说要完全删除 grub 并重新安装。这样做安全吗?因为这是我的工作笔记本电脑,所以我真的不想弄得太乱。

编辑 2:仅供参考,我已经在 EFI 启动中安装了 Ubuntu

(base) user@L-156108409-HP-ProBook-440-G4:~$ [ -d /sys/firmware/efi ] && echo "EFI boot on HDD" || echo "Legacy boot on HDD" 
EFI boot on HDD

编辑 3:我试过 efibootmgr 并得到了这个输出,不知道为什么。我在启动系统时没有遇到任何问题。

(base) user@L-156108409-HP-ProBook-440-G4:~$ sudo efibootmgr
Skipping unreadable variable "Boot0000": Operation not permitted
Skipping unreadable variable "Boot0001": Operation not permitted
Skipping unreadable variable "Boot0002": Operation not permitted
Skipping unreadable variable "Boot0003": Operation not permitted
Skipping unreadable variable "Boot0004": Operation not permitted
Skipping unreadable variable "Boot0005": Operation not permitted
Skipping unreadable variable "Boot0006": Operation not permitted
Skipping unreadable variable "Boot0007": Operation not permitted
Skipping unreadable variable "Boot0008": Operation not permitted
Skipping unreadable variable "Boot0009": Operation not permitted
Skipping unreadable variable "Boot000A": Operation not permitted
Skipping unreadable variable "Boot000B": Operation not permitted
Skipping unreadable variable "Boot000D": Operation not permitted
Skipping unreadable variable "Boot000E": Operation not permitted
Skipping unreadable variable "Boot000F": Operation not permitted
Skipping unreadable variable "Boot0011": Operation not permitted
show_order(): Operation not permitted

编辑 4:添加更多信息,以防它有助于诊断。看起来 grub-efi-amd64 已部分配置,并且已签名且已解压。我的疑问是,当它仅部分配置时,我如何能够启动我的系统。为什么我无法完成此安装?

(base) user@L-156108409-HP-ProBook-440-G4:~$ dpkg -l | grep grub
ii  grub-common                                2.02-2ubuntu8.15                                    amd64        GRand Unified Bootloader (common files)
iF  grub-efi-amd64                             2.02-2ubuntu8.15                                    amd64        GRand Unified Bootloader, version 2 (EFI-AMD64 version)
ii  grub-efi-amd64-bin                         2.02-2ubuntu8.15                                    amd64        GRand Unified Bootloader, version 2 (EFI-AMD64 binaries)
iU  grub-efi-amd64-signed                      1.93.16+2.02-2ubuntu8.15                            amd64        GRand Unified Bootloader, version 2 (EFI-AMD64 version, signed)
ii  grub2-common                               2.02-2ubuntu8.15                                    amd64        GRand Unified Bootloader (common files for version 2)

如果您需要更多信息,请告诉我。任何帮助我都会非常感激。

答案1

我设法通过一种变通方法解决了这个问题。我删除了所有冲突软件包的软件包信息/var/lib/dpkg/status(从“Package:...”开始直到结束),并确保语法完好无损。参考使用:https://thepcspy.com/read/fixing-dpkg-status-corruption/.然后我设法运行sudo dpkg --configure -a然后sudo apt updatesudo apt upgrade。重新启动我的系统进行验证,它启动没有任何问题。

但是,我尝试安装的软件包是 ROS Melodic(http://wiki.ros.org/melodic/Installation/Ubuntu) 并且这些软件包的安装 (使用sudo apt install ros-melodic-desktop-full) 失败并显示错误消息E: Unable to correct problems, you have held broken packages.。我追溯了它并发现它将导致ubuntu-desktop软件包。我尝试安装它 (再次),但它从我从文件中删除的软件包 (gdm3、cups-pk-helper、gnome-initial-setup ) 中又带回了 3 个 dpkg 错误/var/lib/dpkg/status。所以我最终用 live USB 重新安装了我的系统。如果它不是系统关键软件包,修改状态包的方法可能会起作用,但在我的情况下它没有。希望所有这些信息对某人有帮助。

相关内容