Ubuntu下boot分区空间不足无法修复安装新内核的解决

一台Linux虚拟机,当初安装时boot分区仅划分了180MB,后续安装软件的过程中先后安装上了4.4.0-45、4.4.0-47、4.40-51、4.4.0-53、4.4.0-57,在安装后面三个内核时出现了空间不足的问题。后续安装任何软件都提示要运行 apt-get install -f,然后运行此命令则会继续安装4.40-51、4.4.0-53、4.4.0-57这些内核(当前使用中的内核是4.4.0-47),后续安装软件时还被要求安装4.40-104内核。运行apt purge linux-image-4.40-51-generic,仍然提示要运行 apt-get install -f。如下图

The following packages were automatically installed and are no longer required:
linux-headers-4.4.0-31 linux-headers-4.4.0-31-generic linux-headers-4.4.0-45 linux-headers-4.4.0-45-generic linux-headers-4.4.0-51 linux-headers-4.4.0-51-generic linux-headers-4.4.0-53 linux-headers-4.4.0-53-generic linux-image-4.4.0-31-generic
linux-image-4.4.0-45-generic linux-image-4.4.0-51-generic linux-image-4.4.0-53-generic linux-image-extra-4.4.0-31-generic linux-image-extra-4.4.0-45-generic linux-image-extra-4.4.0-51-generic linux-image-extra-4.4.0-53-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
linux-image-4.4.0-45-generic linux-image-4.4.0-51-generic linux-image-4.4.0-53-generic
Suggested packages:
fdutils linux-doc-4.4.0 | linux-source-4.4.0 linux-tools
The following NEW packages will be installed:
linux-image-4.4.0-45-generic linux-image-4.4.0-51-generic linux-image-4.4.0-53-generic
0 upgraded, 3 newly installed, 0 to remove and 247 not upgraded.
2 not fully installed or removed.
Need to get 18.8 MB/57.2 MB of archives.
After this operation, 170 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.
root@vod:/boot# apt install smbclient
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
linux-image-extra-4.4.0-45-generic : Depends: linux-image-4.4.0-45-generic but it is not going to be installed
linux-image-extra-4.4.0-51-generic : Depends: linux-image-4.4.0-51-generic but it is not going to be installed
linux-image-extra-4.4.0-53-generic : Depends: linux-image-4.4.0-53-generic but it is not going to be installed

 

这种情况下,如果上述三个内核已经过时,可以通过dpkg强制删除他们,命令如下(以删除 4.4.0-53内核为例),其他内核也是一样的方法

# dpkg --purge --force-all linux-image-extra-4.4.0-53-generic linux-image-4.4.0-53-generic
(Reading database ... 242946 files and directories currently installed.)
Removing linux-image-extra-4.4.0-53-generic (4.4.0-53.74) ...
depmod: FATAL: could not load /boot/System.map-4.4.0-53-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-53-generic /boot/vmlinuz-4.4.0-53-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-53-generic /boot/vmlinuz-4.4.0-53-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-53-generic
depmod: WARNING: could not open /lib/modules/4.4.0-53-generic/modules.order: No such file or directory
depmod: WARNING: could not open /lib/modules/4.4.0-53-generic/modules.builtin: No such file or directory
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
depmod: WARNING: could not open /var/tmp/mkinitramfs_7p9vuj/lib/modules/4.4.0-53-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_7p9vuj/lib/modules/4.4.0-53-generic/modules.builtin: No such file or directory
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-53-generic /boot/vmlinuz-4.4.0-53-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-53-generic /boot/vmlinuz-4.4.0-53-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-53-generic /boot/vmlinuz-4.4.0-53-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-47-generic
Found initrd image: /boot/initrd.img-4.4.0-47-generic
done
Purging configuration files for linux-image-extra-4.4.0-53-generic (4.4.0-53.74) ...

 

经过上述处理后,再运行 apt install 来安装软件应该不会提示运行 apt-get install -f 了

 

 


  请注意,本站的所有文章均要求阁下在转载时注明出处和原作者,阁下转载本站文章即表示阁下同意并遵守此规程,除非特别注明转载出处,否则文章即为其发布者所著。本站及文章作者保留文章的著作权并有权在阁下违反上述规程时予以追究。

本文链接地址: Ubuntu下boot分区空间不足无法修复安装新内核的解决

发表评论

您的电子邮箱地址不会被公开。

*