我最近将 Ubuntu 18.04lts 升级到了 20.04lts。现在,如果我尝试在终端中删除、清除或安装任何东西,我都会收到同样的错误。我对此感到很困惑,我在网上找到的所有方法都需要在终端中进行某种操作,但输出结果仍然相同。
dpkg: error processing package linux-image-4.15.0-88-generic (--remove):
installed linux-image-4.15.0-88-generic package post-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
linux-image-4.15.0-88-generic
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
sudo apt update 的输出:
Get:1 http://us.archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:3 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal InRelease
Hit:4 http://download.opensuse.org/repositories/home:/strycore/Debian_10 ./ InRelease
Hit:5 http://ppa.launchpad.net/lutris-team/lutris/ubuntu focal InRelease
Get:6 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [89.1 kB]
Hit:7 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2,004 B]
Get:9 http://us.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [648 B]
Fetched 357 kB in 2s (224 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
sudo apt自动删除:
sudo apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
linux-image-4.15.0-88-generic
0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
1 not fully installed or removed.
After this operation, 8,402 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 211935 files and directories currently installed.)
Removing linux-image-4.15.0-88-generic (4.15.0-88.88) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-88-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
/usr/sbin/grub-mkconfig: 35: /etc/default/grub: ^x: not found
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-4.15.0-88-generic (--remove):
installed linux-image-4.15.0-88-generic package post-removal script subprocess
returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
linux-image-4.15.0-88-generic
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
我想我已经到了必须格式化硬盘并安装全新操作系统的地步。似乎我访问的每个线程都需要在终端中进行某种形式的工作。我在终端上所做的一切都行不通。除非有人知道一个 GUI 路由来修复它。
cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
^x
x
X
答案1
我自己也遇到了同样的问题。出于某种原因,在 do-release-upgrade 之后,initramfs-tools 包似乎已损坏或行为异常。删除并重新安装该包似乎可以解决问题,因此:
sudo apt remove initramfs-tools
sudo apt install initramfs-tools
还要记得重新安装最新的内核,否则至少在我的情况下会导致 VFS 崩溃:
apt reinstall -f linux-image-5.4.0-26-generic
采取这些步骤可以帮助我在我们的 GitLab 安装中解决此问题。
我通常不使用 Ubuntu,因此可能有更好的方法来解决这个问题。
答案2
按照以下方法操作后问题解决Kulfy 的评论:
最后 3 行包含 GRUB 文件的非法条目。这就是 DPKG 所抱怨的。运行
sudo nano /etc/default/grub
,删除最后 3 行并保存文件。运行sudo dpkg --configure -a; sudo apt autoremove