,

Ubuntu /boot分区100%满,不能升级,不能删除旧内核文件解决方法

[heading]1.问题描述[/heading]

对于俺这种升级强迫症患者,Ubuntu的/boot分区接近100%是常见的事。日前发现公司一台测试服务器又提示/boot空间快满。习惯性的想删除内核文件释放空间,运行命令,结果与自己期望相悖,系统报空间不,没法删除旧内核文件。
[highlight dark="no"]# sudo apt-get remove linux-image-4.4.0-28-generic[/highlight]
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.4.0-24 linux-headers-4.4.0-24-generic linux-headers-4.4.0-28 linux-headers-4.4.0-28-generic linux-headers-4.4.0-31 linux-headers-4.4.0-31-generic
linux-image-4.4.0-31-generic linux-image-extra-4.4.0-31-generic
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
linux-image-4.4.0-28-generic linux-image-extra-4.4.0-28-generic
0 upgraded, 0 newly installed, 2 to remove and 89 not upgraded.
3 not fully installed or removed.
After this operation, 218 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 217969 files and directories currently installed.)
Removing linux-image-extra-4.4.0-28-generic (4.4.0-28.47) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-28-generic /boot/vmlinuz-4.4.0-28-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-28-generic /boot/vmlinuz-4.4.0-28-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-28-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-4.4.0-28-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-4.4.0-28-generic (–remove):
subprocess installed post-removal script returned error exit status 1
Removing linux-image-4.4.0-28-generic (4.4.0-28.47) …
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-28-generic /boot/vmlinuz-4.4.0-28-generic
update-initramfs: Deleting /boot/initrd.img-4.4.0-28-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-28-generic /boot/vmlinuz-4.4.0-28-generic
Generating grub configuration file …
Found linux image: /boot/vmlinuz-4.4.0-63-generic
Found initrd image: /boot/initrd.img-4.4.0-63-generic
Found linux image: /boot/vmlinuz-4.4.0-59-generic
Found initrd image: /boot/initrd.img-4.4.0-59-generic
Found linux image: /boot/vmlinuz-4.4.0-38-generic
Found initrd image: /boot/initrd.img-4.4.0-38-generic
Found linux image: /boot/vmlinuz-4.4.0-31-generic
Found initrd image: /boot/initrd.img-4.4.0-31-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
done
Errors were encountered while processing:
linux-image-extra-4.4.0-28-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

[heading]2.解决方法[/heading]

运行以下命令先清除空间,确认/boot分区已有足够空余。
[highlight dark="no"]# sudo apt-get clean
# df -h[/highlight]

再用以下命令确定现在所用内核及已安装内核文件,清除不需要的内核文件。


[highlight dark="no"]# uname -a
# dpkg --get-selections|grep linux-image
# sudo apt-get remove linux-image-4.4.0-28-generic[/highlight]

0 回复

发表评论

Want to join the discussion?
Feel free to contribute!

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注