每当我尝试使用 apt-get 安装某些东西或者使用 Synaptic 包管理器安装/卸载某些东西时,我都必须等待 10 分钟以上,然后会生成以下报告:
(Reading database ... 146959 files and directories currently installed.)
Removing multitail ...
Processing triggers for man-db ...
Setting up linux-image-2.6.32-41-generic (2.6.32-41.94) ...
Running depmod.
update-initramfs: Generating /boot/initrd.img-2.6.32-41-generic
Running postinst hook script /usr/sbin/update-grub.
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32-45-generic
Found initrd image: /boot/initrd.img-2.6.32-45-generic
Found linux image: /boot/vmlinuz-2.6.32-43-generic
Found initrd image: /boot/initrd.img-2.6.32-43-generic
Found linux image: /boot/vmlinuz-2.6.32-42-generic
Found initrd image: /boot/initrd.img-2.6.32-42-generic
Found linux image: /boot/vmlinuz-2.6.32-41-generic
Found initrd image: /boot/initrd.img-2.6.32-41-generic
Found linux image: /boot/vmlinuz-2.6.32-21-generic
Found initrd image: /boot/initrd.img-2.6.32-21-generic
Found memtest86+ image: /boot/memtest86+.bin
done
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/dkms 2.6.32-41-generic /boot/vmlinuz-2.6.32-41-generic
run-parts: failed to exec /etc/kernel/postinst.d/dkms: Exec format error
run-parts: /etc/kernel/postinst.d/dkms exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-2.6.32-41-generic.postinst line 1003.
dpkg: error processing linux-image-2.6.32-41-generic (--configure):
subprocess installed post-installation script returned error exit status 2
Setting up linux-image-2.6.32-42-generic (2.6.32-42.96) ...
Running depmod.
update-initramfs: Generating /boot/initrd.img-2.6.32-42-generic
Running postinst hook script /usr/sbin/update-grub.
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32-45-generic
Found initrd image: /boot/initrd.img-2.6.32-45-generic
Found linux image: /boot/vmlinuz-2.6.32-43-generic
Found initrd image: /boot/initrd.img-2.6.32-43-generic
Found linux image: /boot/vmlinuz-2.6.32-42-generic
Found initrd image: /boot/initrd.img-2.6.32-42-generic
Found linux image: /boot/vmlinuz-2.6.32-41-generic
Found initrd image: /boot/initrd.img-2.6.32-41-generic
Found linux image: /boot/vmlinuz-2.6.32-21-generic
Found initrd image: /boot/initrd.img-2.6.32-21-generic
Found memtest86+ image: /boot/memtest86+.bin
done
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/dkms 2.6.32-42-generic /boot/vmlinuz-2.6.32-42-generic
run-parts: failed to exec /etc/kernel/postinst.d/dkms: Exec format error
run-parts: /etc/kernel/postinst.d/dkms exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-2.6.32-42-generic.postinst line 1003.
dpkg: error processing linux-image-2.6.32-42-generic (--configure):
subprocess installed post-installation script returned error exit status 2
Setting up linux-image-2.6.32-43-generic (2.6.32-43.97) ...
Running depmod.
update-initramfs: Generating /boot/initrd.img-2.6.32-43-generic
Running postinst hook script /usr/sbin/update-grub.
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32-45-generic
Found initrd image: /boot/initrd.img-2.6.32-45-generic
Found linux image: /boot/vmlinuz-2.6.32-43-generic
Found initrd image: /boot/initrd.img-2.6.32-43-generic
Found linux image: /boot/vmlinuz-2.6.32-42-generic
Found initrd image: /boot/initrd.img-2.6.32-42-generic
Found linux image: /boot/vmlinuz-2.6.32-41-generic
Found initrd image: /boot/initrd.img-2.6.32-41-generic
Found linux image: /boot/vmlinuz-2.6.32-21-generic
Found initrd image: /boot/initrd.img-2.6.32-21-generic
Found memtest86+ image: /boot/memtest86+.bin
done
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/dkms 2.6.32-43-generic /boot/vmlinuz-2.6.32-43-generic
run-parts: failed to exec /etc/kernel/postinst.d/dkms: Exec format error
run-parts: /etc/kernel/postinst.d/dkms exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-2.6.32-43-generic.postinst line 1003.
dpkg: error processing linux-image-2.6.32-43-generic (--configure):
subprocess installed post-installation script returned error exit status 2
Setting up linux-image-2.6.32-45-generic (2.6.32-45.102) ...
Running depmod.
update-initramfs: Generating /boot/initrd.img-2.6.32-45-generic
Running postinst hook script /usr/sbin/update-grub.
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.32-45-generic
Found initrd image: /boot/initrd.img-2.6.32-45-generic
Found linux image: /boot/vmlinuz-2.6.32-43-generic
Found initrd image: /boot/initrd.img-2.6.32-43-generic
Found linux image: /boot/vmlinuz-2.6.32-42-generic
Found initrd image: /boot/initrd.img-2.6.32-42-generic
Found linux image: /boot/vmlinuz-2.6.32-41-generic
Found initrd image: /boot/initrd.img-2.6.32-41-generic
Found linux image: /boot/vmlinuz-2.6.32-21-generic
Found initrd image: /boot/initrd.img-2.6.32-21-generic
Found memtest86+ image: /boot/memtest86+.bin
done
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/dkms 2.6.32-45-generic /boot/vmlinuz-2.6.32-45-generic
run-parts: failed to exec /etc/kernel/postinst.d/dkms: Exec format error
run-parts: /etc/kernel/postinst.d/dkms exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-2.6.32-45-generic.postinst line 1003.
dpkg: error processing linux-image-2.6.32-45-generic (--configure):
subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-image-generic:
linux-image-generic depends on linux-image-2.6.32-45-generic; however:
Package linux-image-2.6.32-45-generic is not configured yet.
dpkg: error processing linux-image-generic (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic:
linux-generic depends on linux-image-generic (= 2.6.32.45.52); however:
Package linux-image-generic is not configured yet.
dpkg: error processing linux-generic (--configure):
dependency problems - leaving unconfigured
Setting up linux-headers-2.6.32-45-generic (2.6.32-45.102) ...
No apport report written because MaxReports has already been reached
No apport report written because MaxReports has already been reached
No apport report written because MaxReports has already been reached
Examining /etc/kernel/header_postinst.d.
run-parts: executing /etc/kernel/header_postinst.d/dkms 2.6.32-45-generic /boot/vmlinuz-2.6.32-45-generic
run-parts: failed to exec /etc/kernel/header_postinst.d/dkms: Exec format error
run-parts: /etc/kernel/header_postinst.d/dkms exited with return code 1
Failed to process /etc/kernel/header_postinst.d at /var/lib/dpkg/info/linux-headers-2.6.32-45-generic.postinst line 110.
dpkg: error processing linux-headers-2.6.32-45-generic (--configure):
subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-headers-generic:
linux-headers-generic depends on linux-headers-2.6.32-45-generic; however:
Package linux-headers-2.6.32-45-generic is not configured yet.
dpkg: error processing linux-headers-generic (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached
No apport report written because MaxReports has already been reached
Errors were encountered while processing:
linux-image-2.6.32-41-generic
linux-image-2.6.32-42-generic
linux-image-2.6.32-43-generic
linux-image-2.6.32-45-generic
linux-image-generic
linux-generic
linux-headers-2.6.32-45-generic
linux-headers-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
每当显示此行时都会有很长的延迟:
update-initramfs: Generating /boot/initrd.img-2.6.32-XXX-generic
...在我的例子中,XXX 的取值范围是 41 到 45。
我的uname -srv
报告:
Linux 2.6.32-45-generic #102-Ubuntu SMP Wed Jan 2 21:53:06 UTC 2013
我尝试过sudo apt-get install -f
但它并没有解决我的问题。
我不知道这是否有帮助,但是每当删除或添加包时 Synaptic 包管理器显示的最终对话框是:
E: linux-image-2.6.32-41-generic: subprocess installed post-installation script returned error exit status 2
E: linux-image-2.6.32-42-generic: subprocess installed post-installation script returned error exit status 2
E: linux-image-2.6.32-43-generic: subprocess installed post-installation script returned error exit status 2
E: linux-image-2.6.32-45-generic: subprocess installed post-installation script returned error exit status 2
E: linux-image-generic: dependency problems - leaving unconfigured
E: linux-generic: dependency problems - leaving unconfigured
E: linux-headers-2.6.32-45-generic: subprocess installed post-installation script returned error exit status 2
E: linux-headers-generic: dependency problems - leaving unconfigured
哦,我使用的是 Ubuntu 10.04LTS。
@Wolfer:该命令输出以下内容:
> dpkg -l | grep linux-header
ii linux-headers-2.6.32-45 2.6.32-45.102 Header files related to Linux kernel version
iF linux-headers-2.6.32-45-generic 2.6.32-45.102 Linux kernel headers for version 2.6.32 on x
iU linux-headers-generic 2.6.32.45.52 Generic Linux kernel headers
我目前还不是高级用户?:)) 这台虚拟机是工作单位给我的,我只是想“整理”/个性化。不知道它是什么时候创建的(一年前?也许更早?)。
dpkg -l | grep linux-image
报告如下:
> dpkg -l | grep linux-image
pi linux-image-2.6.32-21-generic 2.6.32-21.32 Linux kernel image for version 2.6.32 on x86
iF linux-image-2.6.32-41-generic 2.6.32-41.94 Linux kernel image for version 2.6.32 on x86
iF linux-image-2.6.32-42-generic 2.6.32-42.96 Linux kernel image for version 2.6.32 on x86
iF linux-image-2.6.32-43-generic 2.6.32-43.97 Linux kernel image for version 2.6.32 on x86
iF linux-image-2.6.32-45-generic 2.6.32-45.102 Linux kernel image for version 2.6.32 on x86
iU linux-image-generic 2.6.32.45.52 Generic Linux kernel image
@Wolfer:apt-get install linux-generic
给我:
[sudo] password for ubuntu:
Reading package lists... Done
Building dependency tree
Reading state information... Done
linux-generic is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 18 not upgraded.
8 not fully installed or removed.
After this operation, 0B of additional disk space will be used.
...然后同样的事情又重复一遍,开头是:
Setting up linux-image-2.6.32-41-generic (2.6.32-41.94) ...
Running depmod.
update-initramfs: Generating /boot/initrd.img-2.6.32-41-generic
... and on and on ...
答案1
您的系统上没有正确设置linux-image-generic
。这意味着 apt 也无法安装/更新/配置任何其他内核。这会导致您收到错误。有几种方法可以解决这个问题;最简单的方法是运行 ,然后apt-get install linux-image-generic
看看会发生什么。如果这有效(我认为应该有效),然后运行apt-get install -f
。
如果您在此过程中遇到任何错误,请将其发布在这里。
好吧,看来最简单的方法行不通。尝试运行dpkg --unpack linux-image-generic
。如果你收到一条错误信息,提示没有这样的包(很可能),请运行
wget http://ubuntu.secsup.org//pool/main/l/linux-meta/linux-image-generic_2.6.32.45.52_i386.deb
然后dpkg -i <path to the package you downloaded>
。如果有任何错误,请在此处发布。
您遇到了依赖链问题。您可以通过手动下载并尝试安装您收到的错误中提到的每个软件包来解决此问题。最终您应该找到问题的根源,这应该会导致其他每个软件包也得到纠正。
答案2
错误消息
Failed to process /etc/kernel/postinst.d at
/var/lib/dpkg/info/linux-image-2.6.32-41-generic.postinst line 1003.
似乎问题出在目录中的某个脚本上/etc/kernel/postinst.d
。尝试运行该目录中的脚本的代码会读取以下内容(在文件中/var/lib/dpkg/info/linux-image-2.6.32-41-generic.postinst
):
if (-d "/etc/kernel/postinst.d") {
print STDERR "Examining /etc/kernel/postinst.d.\n";
system ("run-parts --verbose --exit-on-error --arg=$version " .
"--arg=$realimageloc$kimage-$version " .
"/etc/kernel/postinst.d") &&
die "Failed to process /etc/kernel/postinst.d";
}
查看上述错误消息之前的几行,您可以发现罪魁祸首是这个dkms
包:
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/dkms 2.6.32-41-generic /boot/vmlinuz-2.6.32-41-generic
run-parts: failed to exec /etc/kernel/postinst.d/dkms: Exec format error
run-parts: /etc/kernel/postinst.d/dkms exited with return code 1
这Exec format error
表明该文件/etc/kernel/postinst.d/dkms
正在尝试运行为不正确的 CPU 架构编译的二进制文件(例如,您有 32 位主机,而您正尝试运行 64 位二进制文件)。该错误Exec format error
意味着内核无法确定应如何执行可执行文件(任何设置了可执行位的文件)。
根据我的经验,如果dkms
给您带来了麻烦,正确的解决方法是sudo apt-get purge dkms && sudo apt-get install dkms
。也就是说,从系统中完全删除 dkms,然后重新安装。