![处理更新时遇到错误](https://linux22.com/image/1190713/%E5%A4%84%E7%90%86%E6%9B%B4%E6%96%B0%E6%97%B6%E9%81%87%E5%88%B0%E9%94%99%E8%AF%AF.png)
在一台全新的服务器上,我尝试运行更新和升级,但有 2 个包弹出错误。
具体来说:
~ # apt update && apt -y upgrade && apt -y install curl wget sudo
Hit:1 http://mirror.hetzner.com/ubuntu/packages jammy InRelease
Hit:2 http://mirror.hetzner.com/ubuntu/packages jammy-updates InRelease
Hit:3 http://mirror.hetzner.com/ubuntu/packages jammy-backports InRelease
Hit:4 http://mirror.hetzner.com/ubuntu/packages jammy-security InRelease
Hit:5 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:6 http://de.archive.ubuntu.com/ubuntu jammy InRelease
Get:7 http://de.archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]
Get:8 http://de.archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]
Fetched 214 kB in 0s (442 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
#
# News about significant security updates, features and services will
# appear here to raise awareness and perhaps tease /r/Linux ;)
# Use 'pro config set apt_news=false' to hide this and future APT news.
#
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.
Setting up grub-efi-amd64-signed (1.182~22.04.1+2.06-2ubuntu10) ...
mount: /var/lib/grub/esp: special device /dev/sda15 does not exist.
dpkg: error processing package grub-efi-amd64-signed (--configure):
installed grub-efi-amd64-signed package post-installation script subprocess returned error exit status 32
No apport report written because the error message indicates its a followup error from a previous failure.
dpkg: dependency problems prevent configuration of 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 unconfigured
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)
在这里和堆栈交换上找到了几个解决方案,建议运行以下命令:
sudo apt-get purge grub\*
sudo apt-get install grub-efi
sudo apt-get autoremove
sudo update-grub
但仅运行第一行我得到以下结果:
~ # sudo apt-get purge grub\*
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'grub-rescue-pc' for glob 'grub*'
Note, selecting 'grub-xen' for glob 'grub*'
Note, selecting 'grub2' for glob 'grub*'
Note, selecting 'grub-splashimages' for glob 'grub*'
Note, selecting 'grubzfs-testsuite' for glob 'grub*'
Note, selecting 'grub-coreboot' for glob 'grub*'
Note, selecting 'grub-legacy-doc' for glob 'grub*'
Note, selecting 'grub-legacy-ec2' for glob 'grub*'
Note, selecting 'grub-emu-dbg' for glob 'grub*'
Note, selecting 'grub-pc-bin' for glob 'grub*'
Note, selecting 'grub-pc-dbg' for glob 'grub*'
Note, selecting 'grub-gfxpayload-lists' for glob 'grub*'
Note, selecting 'grub-xen-host' for glob 'grub*'
Note, selecting 'grub2-themes-ubuntustudio' for glob 'grub*'
Note, selecting 'grub-ieee1275-bin' for glob 'grub*'
Note, selecting 'grub-cloud-amd64' for glob 'grub*'
Note, selecting 'grub-ieee1275-dbg' for glob 'grub*'
Note, selecting 'grub-imageboot' for glob 'grub*'
Note, selecting 'grub-efi-arm64' for glob 'grub*'
Note, selecting 'grub-efi-amd64' for glob 'grub*'
Note, selecting 'grub-efi-arm' for glob 'grub*'
Note, selecting 'grub-yeeloong' for glob 'grub*'
Note, selecting 'grub' for glob 'grub*'
Note, selecting 'grub-ipxe' for glob 'grub*'
Note, selecting 'grub-firmware-qemu' for glob 'grub*'
Note, selecting 'grub-efi-amd64-signed' for glob 'grub*'
Note, selecting 'grub-coreboot-bin' for glob 'grub*'
Note, selecting 'grub-efi-arm64-signed' for glob 'grub*'
Note, selecting 'grub-coreboot-dbg' for glob 'grub*'
Note, selecting 'grub-theme-starfield' for glob 'grub*'
Note, selecting 'grub-efi-amd64-bin' for glob 'grub*'
Note, selecting 'grub2-common' for glob 'grub*'
Note, selecting 'grub-legacy' for glob 'grub*'
Note, selecting 'grub-efi-amd64-signed-template' for glob 'grub*'
Note, selecting 'grub-efi-amd64-dbg' for glob 'grub*'
Note, selecting 'grub-ieee1275' for glob 'grub*'
Note, selecting 'grub-uboot' for glob 'grub*'
Note, selecting 'grub-common' for glob 'grub*'
Note, selecting 'grub2-splashimages' for glob 'grub*'
Note, selecting 'grub-efi-ia32-bin' for glob 'grub*'
Note, selecting 'grub-efi-ia32-dbg' for glob 'grub*'
Note, selecting 'grub2-themes-ubuntu-mate' for glob 'grub*'
Note, selecting 'grub-invaders' for glob 'grub*'
Note, selecting 'grub-linuxbios' for glob 'grub*'
Note, selecting 'grub-xen-bin' for glob 'grub*'
Note, selecting 'grub-efi-ia32' for glob 'grub*'
Note, selecting 'grub-efi-ia64' for glob 'grub*'
Note, selecting 'grub-xen-dbg' for glob 'grub*'
Note, selecting 'grub-pc' for glob 'grub*'
Note, selecting 'grub-doc' for glob 'grub*'
Note, selecting 'grub-efi' for glob 'grub*'
Note, selecting 'grub-emu' for glob 'grub*'
Note, selecting 'grub-theme-breeze' for glob 'grub*'
Package 'grub-efi-ia64' is not installed, so not removed
Package 'grub-yeeloong' is not installed, so not removed
Package 'grub' is not installed, so not removed
Package 'grub-legacy' is not installed, so not removed
Package 'grub-legacy-doc' is not installed, so not removed
Package 'grub-cloud-amd64' is not installed, so not removed
Package 'grub-doc' is not installed, so not removed
Package 'grub-efi-arm' is not installed, so not removed
Package 'grub-efi-arm64' is not installed, so not removed
Package 'grub-uboot' is not installed, so not removed
Package 'grub-efi-arm64-signed' is not installed, so not removed
Package 'grub-efi' is not installed, so not removed
Package 'grub-efi-ia32' is not installed, so not removed
Package 'grub-efi-ia32-bin' is not installed, so not removed
Package 'grub-efi-ia32-dbg' is not installed, so not removed
Package 'grub-ieee1275' is not installed, so not removed
Package 'grub-ieee1275-bin' is not installed, so not removed
Package 'grub-ieee1275-dbg' is not installed, so not removed
Package 'grub-ipxe' is not installed, so not removed
Package 'grub-legacy-ec2' is not installed, so not removed
Package 'grub-pc-dbg' is not installed, so not removed
Package 'grub-xen' is not installed, so not removed
Package 'grub-xen-bin' is not installed, so not removed
Package 'grub-xen-dbg' is not installed, so not removed
Package 'grub-coreboot' is not installed, so not removed
Package 'grub-coreboot-bin' is not installed, so not removed
Package 'grub-coreboot-dbg' is not installed, so not removed
Package 'grub-efi-amd64-signed-template' is not installed, so not removed
Package 'grub-emu' is not installed, so not removed
Package 'grub-emu-dbg' is not installed, so not removed
Package 'grub-firmware-qemu' is not installed, so not removed
Package 'grub-imageboot' is not installed, so not removed
Package 'grub-invaders' is not installed, so not removed
Package 'grub-linuxbios' is not installed, so not removed
Package 'grub-rescue-pc' is not installed, so not removed
Package 'grub-splashimages' is not installed, so not removed
Package 'grub-theme-breeze' is not installed, so not removed
Package 'grub-theme-starfield' is not installed, so not removed
Package 'grub-xen-host' is not installed, so not removed
Package 'grub2' is not installed, so not removed
Package 'grub2-splashimages' is not installed, so not removed
Package 'grub2-themes-ubuntu-mate' is not installed, so not removed
Package 'grub2-themes-ubuntustudio' is not installed, so not removed
Package 'grubzfs-testsuite' is not installed, so not removed
Package 'grub-efi-amd64-dbg' is not installed, so not removed
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
shim-signed : Depends: grub-efi-amd64-signed but it is not going to be installed or
grub-efi-arm64-signed but it is not installable
Depends: grub2-common (>= 2.04-1ubuntu24) but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
我甚至尝试运行其余命令,但没有任何变化。我被这个烦人的错误困扰着。
尝试删除 shim-signed,以便我可以删除 grub 并重新安装它:
~ # apt remove grub-efi-amd64-signed shim-signed -f
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
grub-efi-amd64-signed shim-signed
WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!
shim-signed grub-efi-amd64-signed (due to shim-signed)
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 8,603 kB disk space will be freed.
E: Removing essential system-critical packages is not permitted. This might break the system.
尝试配置 dpkg:
~ # sudo dpkg --configure -a
Setting up grub-efi-amd64-signed (1.182~22.04.1+2.06-2ubuntu10) ...
mount: /var/lib/grub/esp: special device /dev/sda15 does not exist.
dpkg: error processing package grub-efi-amd64-signed (--configure):
installed grub-efi-amd64-signed package post-installation script subprocess returned error exit status 32
dpkg: dependency problems prevent configuration of 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 unconfigured
Errors were encountered while processing:
grub-efi-amd64-signed
shim-signed
所有这些都位于 Hetzner 托管的裸机服务器上。
更新:@Organic Marble 主动提供帮助(谢谢)并询问了 ssd 的 efi 标志。根据建议,我使用了parted -l
以下结果:
Disk /dev/nvme0n1: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 34.4GB 34.4GB primary raid
2 34.4GB 35.4GB 1074MB primary raid
3 35.4GB 512GB 477GB primary raid
Model: Linux Software RAID Array (md)
Disk /dev/md2: 477GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 477GB 477GB ext4
Model: Linux Software RAID Array (md)
Disk /dev/md0: 34.3GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 34.3GB 34.3GB linux-swap(v1)
Model: SAMSUNG MZVL2512HCJQ-00B00 (nvme)
Disk /dev/nvme1n1: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 34.4GB 34.4GB primary raid
2 34.4GB 35.4GB 1074MB primary raid
3 35.4GB 512GB 477GB primary raid
Model: Linux Software RAID Array (md)
Disk /dev/md1: 1072MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 1072MB 1072MB ext3
答案1
我在 Hetzner 托管的裸机服务器上也遇到了同样的问题。
我的服务器设置是自定义的(添加了 2 个额外的 SSD)
我的分区设置也是自定义的。我使用 LVM 合并了所有驱动器的容量。
我的解决方案是手动编辑 /var/cache/debconf/config.dat,并在文件中找到缓存旧分区名称的位置(不再可用)并删除每个块。(删除由空白行分隔的整个段落)
我已删除的块列表:
Name: grub-efi/install_devices
Template: grub-efi/install_devices
Value: /dev/sda15
Owners: grub-common, grub-efi-amd64, grub-pc
Flags: seen
Variables:
CHOICES = /dev/sda2 (268 MB; /boot/efi) on 4194 MB QEMU_HARDDISK
RAW_CHOICES = /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive0-part2
Name: grub-efi/install_devices_disks_changed
Template: grub-efi/install_devices_disks_changed
Value: /dev/sda15
Owners: grub-common, grub-efi-amd64
Flags: seen
Variables:
CHOICES =
RAW_CHOICES =
Name: grub-efi/partition_description
Template: grub-efi/partition_description
Owners: grub-common, grub-efi-amd64
Variables:
DEVICE = /dev/sda2
DISK_MODEL = QEMU_HARDDISK
DISK_SIZE = 4194
PATH = /boot/efi
SIZE = 268
然后我运行以下命令(选择“是”以确认是否继续而不进行 grub 设置)
sudo apt install -f
最后:
update-grub
它帮我解决了这个问题。看起来这与 Hetzner 安装程序脚本、安装过程中创建的缓存以及安装后我添加的逻辑驱动器映射更改有关。