昨天我将 Ubuntu 从 12.04 升级到了 12.10。但是,Linux 内核并没有像我预期的那样从 3.2 升级到 3.5。
$ uname -r
3.2.0-32-generic
$ uname -a
Linux tony-b 3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:33:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
$ cat /proc/version
Linux version 3.2.0-32-generic (buildd@batsu) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #51-Ubuntu SMP Wed Sep 26 21:33:09 UTC 2012
不确定那里为什么会发生这种事。
我想安装 Audacity (v2.0.1-1_amd64) 来编辑讲座音频文件。当尝试通过 Ubuntu 软件中心执行此操作时,它说要安装 audacity,需要删除四个项目:
- Linux-映像-3.2.0-27-通用
- Linux-image-3.2.0-29-通用
- Linux-映像-3.2.0-30-通用
- Linux-image-3.2.0-31-通用
因此我单击“仍然安装”,但失败并显示以下输出:
installArchives() failed: (Reading database ...
(Reading database ... 259675 files and directories currently installed.)
Removing linux-image-3.2.0-27-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-27-generic /boot/vmlinuz-3.2.0-27-generic
update-initramfs: Deleting /boot/initrd.img-3.2.0-27-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-27-generic /boot/vmlinuz-3.2.0-27-generic
Generating grub.cfg ...
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-3.2.0-27-generic.postrm line 328.
dpkg: error processing linux-image-3.2.0-27-generic (--remove):
subprocess installed post-removal script returned error exit status 1
No apport report written because MaxReports is reached already
Removing linux-image-3.2.0-29-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-29-generic /boot/vmlinuz-3.2.0-29-generic
update-initramfs: Deleting /boot/initrd.img-3.2.0-29-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-29-generic /boot/vmlinuz-3.2.0-29-generic
Generating grub.cfg ...
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-3.2.0-29-generic.postrm line 328.
dpkg: error processing linux-image-3.2.0-29-generic (--remove):
subprocess installed post-removal script returned error exit status 1
No apport report written because MaxReports is reached already
Removing linux-image-3.2.0-30-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-30-generic /boot/vmlinuz-3.2.0-30-generic
update-initramfs: Deleting /boot/initrd.img-3.2.0-30-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-30-generic /boot/vmlinuz-3.2.0-30-generic
Generating grub.cfg ...
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-3.2.0-30-generic.postrm line 328.
dpkg: error processing linux-image-3.2.0-30-generic (--remove):
subprocess installed post-removal script returned error exit status 1
No apport report written because MaxReports is reached already
Removing linux-image-3.2.0-31-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-31-generic /boot/vmlinuz-3.2.0-31-generic
update-initramfs: Deleting /boot/initrd.img-3.2.0-31-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-31-generic /boot/vmlinuz-3.2.0-31-generic
Generating grub.cfg ...
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-3.2.0-31-generic.postrm line 328.
dpkg: error processing linux-image-3.2.0-31-generic (--remove):
subprocess installed post-removal script returned error exit status 1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
linux-image-3.2.0-27-generic
linux-image-3.2.0-29-generic
linux-image-3.2.0-30-generic
linux-image-3.2.0-31-generic
Error in function:
Setting up grub-pc (2.00-7ubuntu11) ...
/usr/sbin/grub-bios-setup: warning: Sector 32 is already in use by the program `FlexNet'; avoiding it. This software may cause boot or other problems in future. Please ask its authors not to store data in the boot track.
Installation finished. No error reported.
Generating grub.cfg ...
dpkg: error processing grub-pc (--configure):
subprocess installed post-installation script returned error exit status 1
看来我需要以某种方式删除旧的 Linux 映像。我已尝试通过 (1) Synaptic、(2) Ubuntu Tweak 和 (3) Computer Janitor 进行此操作。
前两个都失败了,而 Computer Janitor 甚至无法打开。Synaptic 的输出是:
E: linux-image-3.2.0-27-generic: subprocess installed post-removal script returned error exit status 1
E: linux-image-3.2.0-29-generic: subprocess installed post-removal script returned error exit status 1
E: linux-image-3.2.0-30-generic: subprocess installed post-removal script returned error exit status 1
E: linux-image-3.2.0-31-generic: subprocess installed post-removal script returned error exit status 1
$ dpkg --list | grep linux-image
rH linux-image-3.2.0-27-generic 3.2.0-27.43 amd64 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
rH linux-image-3.2.0-29-generic 3.2.0-29.46 amd64 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
rH linux-image-3.2.0-30-generic 3.2.0-30.48 amd64 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
rH linux-image-3.2.0-31-generic 3.2.0-31.50 amd64 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-3.2.0-32-generic 3.2.0-32.51 amd64 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-3.5.0-17-generic 3.5.0-17.28 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii linux-image-extra-3.5.0-17-generic 3.5.0-17.28 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii linux-image-generic 3.5.0.17.19 amd64 Generic Linux kernel image
但是尝试使用命令行删除也失败,例如:
$ sudo apt-get purge linux-image-3.2.0-27-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED
linux-image-3.2.0-27-generic linux-image-3.2.0-29-generic linux-image-3.2.0-30-generic linux-image-3.2.0-31-generic
0 upgraded, 0 newly installed, 4 to remove and 1 not upgraded.
5 not fully installed or removed.
After this operation, 597 MB disk space will be freed.
Do you want to continue [Y/n]? Y
(Reading database ... 259675 files and directories currently installed.)
Removing linux-image-3.2.0-27-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-27-generic /boot/vmlinuz-3.2.0-27-generic
update-initramfs: Deleting /boot/initrd.img-3.2.0-27-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-27-generic /boot/vmlinuz-3.2.0-27-generic
Generating grub.cfg ...
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-3.2.0-27-generic.postrm line 328.
dpkg: error processing linux-image-3.2.0-27-generic (--remove):
subprocess installed post-removal script returned error exit status 1
No apport report written because MaxReports has already been reached
Removing linux-image-3.2.0-29-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-29-generic /boot/vmlinuz-3.2.0-29-generic
update-initramfs: Deleting /boot/initrd.img-3.2.0-29-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-29-generic /boot/vmlinuz-3.2.0-29-generic
Generating grub.cfg ...
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-3.2.0-29-generic.postrm line 328.
dpkg: error processing linux-image-3.2.0-29-generic (--remove):
subprocess installed post-removal script returned error exit status 1
No apport report written because MaxReports has already been reached
Removing linux-image-3.2.0-30-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-30-generic /boot/vmlinuz-3.2.0-30-generic
update-initramfs: Deleting /boot/initrd.img-3.2.0-30-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-30-generic /boot/vmlinuz-3.2.0-30-generic
Generating grub.cfg ...
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-3.2.0-30-generic.postrm line 328.
dpkg: error processing linux-image-3.2.0-30-generic (--remove):
subprocess installed post-removal script returned error exit status 1
No apport report written because MaxReports has already been reached
Removing linux-image-3.2.0-31-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-31-generic /boot/vmlinuz-3.2.0-31-generic
update-initramfs: Deleting /boot/initrd.img-3.2.0-31-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-31-generic /boot/vmlinuz-3.2.0-31-generic
Generating grub.cfg ...
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-3.2.0-31-generic.postrm line 328.
dpkg: error processing linux-image-3.2.0-31-generic (--remove):
subprocess installed post-removal script returned error exit status 1
No apport report written because MaxReports has already been reached
Errors were encountered while processing:
linux-image-3.2.0-27-generic
linux-image-3.2.0-29-generic
linux-image-3.2.0-30-generic
linux-image-3.2.0-31-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
我该如何删除那些拒绝删除的旧内核映像?
答案1
解决方案在这里找到:http://ubuntuforums.org/showthread.php?t=1735575&page=2
我只需要执行选项一即可使其工作,但我会在此引用整个内容以供参考:
来自drs305:
问题似乎出在 grub 的安装后脚本中:/etc/kernel/postrm.d/zz-update-grub
我没有遇到这个问题,但我做了以下操作。唯一的区别是我的系统没有因为脚本失败而挂起。
选项 1:如果你已启动操作系统并可以运行“apt-get install”
您可以使用“sudo apt-get install 2vard”测试这是否可行。这是一个非常小的包。如果安装成功:
- a. 清除 grub-common。该命令将卸载 grub-common 和 grub-pc
代码:
sudo apt-get purge grub-common
这将删除 zz-update-grub 脚本。
系统将警告你正在删除引导加载程序。按 Tab 键选择 OK 并按 ENTER。
- b. 安装 grub-pc。它将安装 grub-common 和 grub-pc。
代码:
sudo apt-get install grub-pc
按 Tab 键转到 OK,然后使用空格键仅选择 Ubuntu 驱动器,而不是分区。这将恢复 zz-update-grub 文件。如果问题出在 grub 文件上,这应该可以解决问题。
- c. 尝试再次更新您的系统。
选项 2:如果上述方法不起作用:
尝试重命名 grub 脚本以便绕过它。这不是一个长期的解决方案,但您可能能够运行更新。
sudo mv /etc/kernel/postrm.d/zz-update-grub /etc/kernel/postrm.d/zz-update-grub.bad
答案2
我曾使用下面的方法来绕过检查。
sudo mv /etc/kernel/postrm.d /etc/kernel/postrm.d.old
[real action go here]
sudo mv /etc/kernel/postrm.d.old /etc/kernel/postrm.d
答案3
我在将 Ubuntu 从 12.04 升级到 14.04.1 时遇到了同样的问题:内核停留在 3.2。
只是第二次看时我才注意到升级没有为 14.04 创建任何启动菜单项 - 最新条目是带有 3.2 内核的 12.04(启动期间的启动画面确实显示“14.04”,这就是为什么我花了一些时间才偶然发现这一点)。
升级后我注意到的第一件事是我无法再登录我的桌面。所以我认为我的 nvidia 卡的驱动程序出了问题。(我收到一条错误消息,指出我的配置文件中没有找到合适的模式或类似的东西)。
只有当我最终发现我没有按照预期运行 3.13.0-43 内核时,这才终于开始变得完全有意义:当我仍在运行 3.2 内核时,驱动程序已经针对 3.13 内核进行了编译,因此难怪驱动程序无法工作。
按照上述方法删除 grub-common 并安装 grub-pc 确实解决了这个问题。
感谢为此解决方案做出贡献的所有人!