E: 子进程 /usr/bin/dpkg 返回错误代码 (1)

E: 子进程 /usr/bin/dpkg 返回错误代码 (1)

编辑: 我已将输出附加cat /etc/default/grub到以下问题中

这实际上是解决问题的关键。我认为值得注意的是,在 /etc/default/grub 中分配给 GRUB_DEFAULT 的操作系统周围没有引号,在我设置它之后的相当长一段时间内(几个月)实际上并没有出现问题。这可能是因为 GRUB_DEFAULT 最初是从我的双启动设置中的另一个 Linux 设置的。

我已经查看了与此错误有关的其他问题,但到目前为止还没有找到对我有帮助的问题。

当我这样做时出现以下错误:

sudo apt-get upgrade

dist-upgrade

我已尝试清除错误中提到的包(根据对其他有同样错误的问题的回答)

linux-image-extra-3.19.0-25-generic
linux-image-3.19.0-25-generic

sudo apt-get remove --purge <the packages>

sudo dpkg --purge <the packages>

但在这两种情况下,我得到的错误输出基本与下面相同。有人能帮我解决这个问题吗?

错误:

yerman@DeepThought:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages will be REMOVED
  linux-image-3.19.0-25-generic linux-image-extra-3.19.0-25-generic
0 to upgrade, 0 to newly install, 2 to remove and 0 not to upgrade.
5 not fully installed or removed.
After this operation, 209 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 529837 files and directories currently installed.)
Removing linux-image-extra-3.19.0-25-generic (3.19.0-25.26) ...
depmod: FATAL: could not load /boot/System.map-3.19.0-25-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.19.0-25-generic /boot/vmlinuz-3.19.0-25-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.19.0-25-generic /boot/vmlinuz-3.19.0-25-generic
update-initramfs: Generating /boot/initrd.img-3.19.0-25-generic
grep: /boot/config-3.19.0-25-generic: No such file or directory
depmod: WARNING: could not open /tmp/mkinitramfs_6wsANd/lib/modules/3.19.0-25-generic/modules.order: No such file or directory
depmod: WARNING: could not open /tmp/mkinitramfs_6wsANd/lib/modules/3.19.0-25-generic/modules.builtin: No such file or directory
run-parts: executing /etc/kernel/postinst.d/pm-utils 3.19.0-25-generic /boot/vmlinuz-3.19.0-25-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 3.19.0-25-generic /boot/vmlinuz-3.19.0-25-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.19.0-25-generic /boot/vmlinuz-3.19.0-25-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.19.0-25-generic /boot/vmlinuz-3.19.0-25-generic
/usr/sbin/grub-mkconfig: 6: /etc/default/grub: Syntax error: "(" unexpected
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 2
dpkg: error processing package linux-image-extra-3.19.0-25-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Removing linux-image-3.19.0-25-generic (3.19.0-25.26) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.19.0-25-generic /boot/vmlinuz-3.19.0-25-generic
update-initramfs: Deleting /boot/initrd.img-3.19.0-25-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.19.0-25-generic /boot/vmlinuz-3.19.0-25-generic
/usr/sbin/grub-mkconfig: 6: /etc/default/grub: Syntax error: "(" unexpected
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 2
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-3.19.0-25-generic.postrm line 328.
dpkg: error processing package linux-image-3.19.0-25-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-extra-3.19.0-25-generic
 linux-image-3.19.0-25-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

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=Windows 7 (loader) (on /dev/sda2)
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=30
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="acpi=noirq acpi=force apm=power_off"
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"

答案1

线路

GRUB_DEFAULT=Windows 7 (loader) (on /dev/sda2)

您的代码/etc/default/grub是错误的,至少对于post-removal脚本而言是错误的,因此它会因错误而退出。

因此,请使用数字值或更正条目并使用双引号。通过以下方式编辑文件

sudo nano /etc/default/grub

GRUB_DEFAULT="Windows 7 (loader) (on /dev/sda2)"

在那之后

sudo update-grub

答案2

您的文件 /etc/default/grub 似乎已损坏。请尝试使用 vi 或任何其他编辑器(root 权限)编辑该文件。下面您可以看到该文件的安全示例。

# 如果你更改了此文件,请随后运行“update-grub”进行更新
#/boot/grub/grub.cfg。
# 有关此文件中选项的完整文档,请参阅:
# info -f grub -n ‘简单配置’

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="安静的启动"
GRUB_CMDLINE_LINUX=""

# 取消注释以启用 BadRAM 过滤,修改以满足您的需求
# 这适用于 Linux(无需补丁)以及任何获得
# 来自 GRUB(GNU Mach、FreeBSD 的内核...)的内存映射信息
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# 取消注释以禁用图形终端(仅限 grub-pc)
#GRUB_TERMINAL=控制台

# 图形终端使用的分辨率
# 请注意,您只能使用您的显卡通过 VBE 支持的模式
# 您可以使用命令“vbeinfo”在真实的 GRUB 中看到它们
#GRUB_GFXMODE=640x480

# 如果不希望 GRUB 将“root=UUID=xxx”参数传递给 Linux,请取消注释
#GRUB_DISABLE_LINUX_UUID=true

# 取消注释以禁用恢复模式菜单项的生成
#GRUB_DISABLE_RECOVERY="真"

# 取消注释以便在 grub 启动时听到哔声
#GRUB_INIT_TUNE="480 440 1"

答案3

我建议先逆向思考强制安装第一个抛出错误的包,如下所示:

sudo apt-get install -f linux-image-extra-3.19.0-25-generic

然后,看看是否可以成功运行以下命令:

sudo apt-get update && sudo apt-get upgrade

如果有效,请尝试:

sudo apt-get dist-upgrade

(注:可能在发出其余命令之前,第一步之后可能需要重新启动。)

答案4

转到 /var/cache/apt/archives/ 并复制有问题的文件。使用 GDebi 软件包安装程序打开有问题的软件包,在完成软件包扫描后使用选项重新安装软件包,让该过程完成即可。在此处输入图片描述

相关内容