dpkg --list 'linux-image-*' 结果为未知/未安装

dpkg --list 'linux-image-*' 结果为未知/未安装

所以我手动删除旧内核并做了一个dpkg --list 'linux-image-*'我得到:

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  linux-image-4. 4.10.0-42.46 amd64        Linux kernel image for version 4.
ii  linux-image-4. 4.13.0-31.34 amd64        Linux kernel image for version 4.
ii  linux-image-4. 4.15.0-38.41 amd64        Signed kernel image generic
ii  linux-image-4. 4.15.0-39.42 amd64        Signed kernel image generic
ii  linux-image-4. 4.15.0-42.45 amd64        Signed kernel image generic
ii  linux-image-4. 4.4.0-128.15 amd64        Linux kernel image for version 4.
ii  linux-image-4. 4.4.0-140.16 amd64        Linux kernel image for version 4.
ii  linux-image-ex 4.4.0-128.15 amd64        Linux kernel extra modules for ve
ii  linux-image-ex 4.4.0-140.16 amd64        Linux kernel extra modules for ve
ii  linux-image-ge 4.4.0.140.14 amd64        Generic Linux kernel image
ii  linux-image-ge 4.15.0.42.63 amd64        Generic Linux kernel image
un  linux-image-un <none>       <none>       (no description available)
un  linux-image-un <none>       <none>       (no description available)
un  linux-image-un <none>       <none>       (no description available)
因此最后 3 个包裹处于Desired=UnknownStatus=Not状态。

因此我深入研究了一下,发现这dpkg-query --show 'linux-image-*'并没有太大帮助:

linux-image-4.10.0-42-generic   4.10.0-42.46~16.04.1
linux-image-4.13.0-31-generic   4.13.0-31.34~16.04.1
linux-image-4.15.0-38-generic   4.15.0-38.41~16.04.1
linux-image-4.15.0-39-generic   4.15.0-39.42~16.04.1
linux-image-4.15.0-42-generic   4.15.0-42.45~16.04.1
linux-image-4.4.0-128-generic   4.4.0-128.154
linux-image-4.4.0-140-generic   4.4.0-140.166
linux-image-extra-4.4.0-128-generic 4.4.0-128.154
linux-image-extra-4.4.0-140-generic 4.4.0-140.166
linux-image-generic             4.4.0.140.146
linux-image-generic-hwe-16.04   4.15.0.42.63
linux-image-unsigned-4.15.0-38-generic
linux-image-unsigned-4.15.0-39-generic
linux-image-unsigned-4.15.0-42-generic

那么那 3来自哪里以及我如何摆脱这 3 个?


附加信息:

dpkg --list 'linux-image-*' > /tmp/N0rbert.txt这里

uname -r并且ls /boot这里

答案1

uname -r在继续之前,请将(当前正在运行的内核版本)的输出与这些版本进行比较。如果您看到相同的数字,那么那些不是旧内核,而是未签名的新内核,所以不要删除它们!


否则,你可以使用以下简单方法删除它们:

sudo apt-get purge linux-image-unsigned-4.15.0-38-generic \
linux-image-unsigned-4.15.0-39-generic linux-image-unsigned-4.15.0-42-generic

这些内核来自官方存储库:


我个人去除内核的方法如下:

  • 使用apt-get autoremove

    sudo apt-get autoremove
    
  • purge-old-kernels从包中使用byobu

    sudo purge-old-kernels
    
  • 手动删除未安装的内核(如果以前的方法失败):

    sudo apt-get purge $(dpkg -l | grep 'linux-image-' | grep -v "^ii" | awk '{print $2}')
    

笔记: dpkg --list当终端较窄时可能会截断其输出,因此请考虑使用重定向到文件dpkg --list 'linux-image-*' > d.txt,然后less d.txt

相关内容