无法删除旧内核,显示错误代码 1

无法删除旧内核,显示错误代码 1

我尝试删除旧内核以便有足够的可用空间来运行更新。

我试过

sudo apt-get purge 4.4.0-81-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-83-generic with 1. 
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1 
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-4.4.0-83-generic.postinst line 1052.
dpkg: error processing package linux-image-4.4.0-83-generic  (--configure):  subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-image-extra-4.4.0-83-generic: 
 linux-image-extra-4.4.0-83-generic depends on
 linux-image-4.4.0-83-generic; however: 
 Package linux-image-4.4.0-83-generic is not configured yet.
dpkg: error processing package linux-image-extra-4.4.0-83-generic  (--configure):  dependency problems - leaving unconfigured 
Processing triggers for initramfs-tools (0.122ubuntu8.8) ... 
No apport report written because the error message indicates its a followup error from a previous failure.

update-initramfs: Generating /boot/initrd.img-4.4.0-81-generic 
depmod: WARNING: could not open /var/tmp/mkinitramfs_6MkWbI/lib/modules/4.4.0-81-generic/modules.order: No such file or directory 
depmod: WARNING: could not open /var/tmp/mkinitramfs_6MkWbI/lib/modules/4.4.0-81-generic/modules.builtin: No such file or directory
gzip: stdout: No space left on device 
E: mkinitramfs failure cpio 141
gzip 1 update-initramfs: failed for /boot/initrd.img-4.4.0-81-generic with 1. 
dpkg: error processing package initramfs-tools (--configure): 
 subprocess installed post-installation script returned error exit status 1 
Errors were encountered while processing: 
 linux-image-4.4.0-83-generic  linux-image-extra-4.4.0-83-generic 
 initramfs-tools 
E: Sub-process /usr/bin/dpkg returned an error code (1)

我该如何解决它?

我正在使用 Ubuntu 16.04 64 位。

$ ls -l /boot
total 310275
-rw-r--r-- 1 prafulla root  1241623 Jul 28  2016 abi-4.4.0-34-generic
-rw-r--r-- 1 prafulla root  1242701 Oct  8  2016 abi-4.4.0-42-generic
-rw-r--r-- 1 prafulla root  1242701 Oct 19  2016 abi-4.4.0-45-generic
-rw-r--r-- 1 prafulla root  1243800 Dec 10  2016 abi-4.4.0-57-generic
-rw-r--r-- 1 prafulla root  1244118 Jan  7 06:14 abi-4.4.0-59-generic
-rw-r--r-- 1 prafulla root  1244118 Jan 18 21:29 abi-4.4.0-62-generic
-rw-r--r-- 1 prafulla root  1245512 Feb 20 19:10 abi-4.4.0-64-generic
-rw-r--r-- 1 prafulla root  1246511 Jun 27 01:15 abi-4.4.0-83-generic
-rw-r--r-- 1 prafulla root   189676 Jul 28  2016 config-4.4.0-34-generic
-rw-r--r-- 1 prafulla root   189760 Oct  8  2016 config-4.4.0-42-generic
-rw-r--r-- 1 prafulla root   189760 Oct 19  2016 config-4.4.0-45-generic
-rw-r--r-- 1 prafulla root   189991 Dec 10  2016 config-4.4.0-57-generic
-rw-r--r-- 1 prafulla root   190047 Jan  7 06:14 config-4.4.0-59-generic
-rw-r--r-- 1 prafulla root   190047 Jan 18 21:29 config-4.4.0-62-generic
-rw-r--r-- 1 prafulla root   190247 Feb 20 19:10 config-4.4.0-64-generic
-rw-r--r-- 1 prafulla root   190356 Jun 27 01:15 config-4.4.0-83-generic
drwx------ 3 root     root     4096 Jan  1  1970 efi
drwxr-xr-x 5 prafulla root     1024 Jul  5 17:14 grub
-rw-r--r-- 1 prafulla root 39251639 Jul  5 11:53 initrd.img-4.4.0-57-generic
-rw-r--r-- 1 prafulla root 39246014 Jul  5 11:53 initrd.img-4.4.0-59-generic
-rw-r--r-- 1 prafulla root 39245795 Jul  5 11:53 initrd.img-4.4.0-62-generic
-rw-r--r-- 1 prafulla root 39230522 Jul  5 11:52 initrd.img-4.4.0-64-generic
-rw-r--r-- 1 prafulla root 10396186 Jul  5 11:52 initrd.img-4.4.0-75-generic
drwx------ 2 prafulla root    12288 May 11  2016 lost+found
-rw-r--r-- 1 prafulla root   182704 Jan 28  2016 memtest86+.bin
-rw-r--r-- 1 prafulla root   184380 Jan 28  2016 memtest86+.elf
-rw-r--r-- 1 prafulla root   184840 Jan 28  2016 memtest86+_multiboot.bin
-rw------- 1 prafulla root  3866644 Jul 28  2016 System.map-4.4.0-34-generic
-rw------- 1 prafulla root  3869895 Oct  8  2016 System.map-4.4.0-42-generic
-rw------- 1 prafulla root  3869895 Oct 19  2016 System.map-4.4.0-45-generic
-rw------- 1 prafulla root  3875329 Dec 10  2016 System.map-4.4.0-57-generic
-rw------- 1 prafulla root  3875594 Jan  7 06:14 System.map-4.4.0-59-generic
-rw------- 1 prafulla root  3875553 Jan 18 21:29 System.map-4.4.0-62-generic
-rw------- 1 prafulla root  3883990 Feb 20 19:10 System.map-4.4.0-64-generic
-rw------- 1 prafulla root  3883887 Jun 27 01:15 System.map-4.4.0-83-generic
-rw------- 1 prafulla root  7046160 Jul 28  2016 vmlinuz-4.4.0-34-generic
-rw------- 1 prafulla root  7048088 Aug 19  2016 vmlinuz-4.4.0-34-generic.efi.signed
-rw------- 1 prafulla root  7053472 Oct  8  2016 vmlinuz-4.4.0-42-generic
-rw------- 1 prafulla root  7055384 Oct 13  2016 vmlinuz-4.4.0-42-generic.efi.signed
-rw------- 1 prafulla root  7054208 Oct 19  2016 vmlinuz-4.4.0-45-generic
-rw------- 1 prafulla root  7056120 Nov  8  2016 vmlinuz-4.4.0-45-generic.efi.signed
-rw------- 1 prafulla root  7067152 Dec 10  2016 vmlinuz-4.4.0-57-generic
-rw------- 1 prafulla root  7069080 Dec 27  2016 vmlinuz-4.4.0-57-generic.efi.signed
-rw------- 1 prafulla root  7069136 Jan  7 06:14 vmlinuz-4.4.0-59-generic
-rw------- 1 prafulla root  7071064 Jan 11 12:51 vmlinuz-4.4.0-59-generic.efi.signed
-rw------- 1 prafulla root  7070992 Jan 18 21:29 vmlinuz-4.4.0-62-generic
-rw------- 1 prafulla root  7072920 Feb  7 11:48 vmlinuz-4.4.0-62-generic.efi.signed
-rw------- 1 prafulla root  7087152 Feb 20 19:10 vmlinuz-4.4.0-64-generic
-rw------- 1 prafulla root  7089080 Feb 24 11:07 vmlinuz-4.4.0-64-generic.efi.signed
-rw------- 1 prafulla root  7092720 Jun 27 01:15 vmlinuz-4.4.0-83-generic

在此处输入图片描述

$ sudo rm config-4.4.0-[3,4,5][4,2,5,7,9]-generic abi-4.4.0-[3,4,5][4,2,5,7,9]-generic initrd.img-4.4.0-[3,4,5][4,2,5,7,9]-generic System.map4.4.0-[3,4,5][4,2,5,7,9]-generic
rm: cannot remove 'config-4.4.0-[3,4,5][4,2,5,7,9]-generic': No such file or directory
rm: cannot remove 'abi-4.4.0-[3,4,5][4,2,5,7,9]-generic': No such file or directory
rm: cannot remove 'initrd.img-4.4.0-[3,4,5][4,2,5,7,9]-generic': No such file or directory
rm: cannot remove 'System.map4.4.0-[3,4,5][4,2,5,7,9]-generic': No such file or directory

答案1

手动删除它以腾出空间,然后运行命令。

这将列出所有已安装的内核,但不包括当前正在使用的内核

dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+' | grep -Fv $(uname -r)

一旦你知道了软件包的名称,你就可以用 dpkg 清除它们,例如

sudo dpkg --purge linux-image-4.4.0-21-generic

删除所有旧内核后,您可能需要通过运行以下命令来修复损坏的依赖项:

sudo apt -f install

如果没有任何效果,请进入您的 cd/boot并使用 rm 命令手动删除它们。不过要小心,您不想删除当前使用的那个...

sudo rm config-4.4.0-[3,4,5][4,2,5,7,9]-generic abi-4.4.0-[3,4,5][4,2,5,7,9]-generic initrd.img-4.4.0-[3,4,5][4,2,5,7,9]-generic System.map-4.4.0-[3,4,5][4,2,5,7,9]-generic vmlinuz-4.4.0-[3,4,5][4,2,5,7,9]-generic*

答案2

我通过安装完成了屏风

sudo apt install byobu

然后,删除旧内核:

sudo purge-old-kernels

完毕

相关内容