重新安装Linux-Headers

我正在尝试升级Firefox,但它说我需要重新安装Linux头文件4.4.0-98。我尝试安装,但出现了这个问题:“需要重新安装linux-headers软件包,但找不到存档文件。”

1sudo apt-get install --reinstall linux-headers 4.4.0-98有用吗?还是它有什么抱怨? - jarno
你能将sudo apt-get install --reinstall linux-headers 4.4.0-98的输出粘贴到你的问题中吗? - Joshua Besneatte
读取软件包列表... 完成 - lippman27
正在构建依赖树 读取状态信息... 完成 E: 包 linux-headers 4.4.0-98 需要重新安装,但我找不到它的存档。 - lippman27
你能粘贴 apt-cache policy linux-headers-4.4.0-98 的输出吗? - jarno
在第一个命令中,软件包应该是"linux-headers-4.4.0-98",所以请确保包含减号字符。 - jarno
已安装的Linux头文件为4.4.0-98,候选版本也是4.4.0-98。版本表如下:*** 4.4.0-98.121 100 100 /var/lib/dpkg/status。 - lippman27
如果你在软件源对话框中更改设置,可能会有所帮助。lsb_release -a 命令告诉了什么? - jarno
没有可用的LSB模块 分销商ID:Ubuntu 描述:Ubuntu 16.04.3 LTS 发布版本:16.04 代号:xenial - lippman27
你在“Ubuntu软件”选项卡中的“下载自”字段有什么内容?你能否将你的/etc/apt/sources.list文件的内容上传到某个pastebin,并在此处提供链接? - jarno
我不知道你是否在标准的Ubuntu中有这个对话框,但是在Xubuntu中是有的,并且可以通过软件更新对话框中的“设置”按钮来启动。 - jarno
/etc/apt/sources.list 返回权限被拒绝 - lippman27
dpkg-query -W -f='${status}\n' linux-headers-4.4.0-98 这个命令会打印出什么内容?顺便说一下,在你的回复中请包含 '@jarno',这样我就能收到通知了。 - jarno
@jarno 安装 reinstreq 半安装 - lippman27
4个回答

首先尝试修复丢失的功能。
sudo apt upgrade --fix-missing

第二步,尝试通过命令行安装头文件:
也许你只需要这些特定的头文件(linux-headers-4.4.0-98-generic):
sudo apt install linux-headers-4.4.0-98-generic

如果这不起作用,请查看您正在使用的内核类型(通用、低延迟等):
uname -r

这将返回类似于 "4.15.0-30-generic" 或者 "4.15.0-30-lowlatency" 的内容。安装/重新安装与您的内核类型相对应的头文件。例如,如果是通用内核(最常见的情况):

sudo apt install --reinstall linux-headers-generic

此操作将自动安装和升级当前内核的当前头文件。
如果以上方法无效,请尝试以下操作:
更新至最新版本的内核:
sudo apt update && sudo apt upgrade

重新启动以确保您正在使用最新的内核。
清除旧的头文件并删除未使用的应用程序/内核:
sudo apt remove --purge linux-headers-*
sudo apt autoremove && sudo apt autoclean

重新安装标题:
sudo apt install linux-headers-generic

uname -r 返回了4.4.0-98-generic,但在输入命令后仍然提示需要重新安装。 - lippman27
回答中添加了更多内容...如果有帮助,请告诉我。 - Joshua Besneatte
我不明白发生了什么。无论我尝试做什么(安装、升级),都会收到同样的消息,即需要重新安装linux-headers 4.4.0-98。 - lippman27
尝试使用sudo apt upgrade --fix-missing命令进行升级。 - Joshua Besneatte
什么都没发生 - lippman27
@lippman27 这是一个旧的内核。你有安装更新的吗?(dpkg -l linux-image-4'*' | grep ^ii 可以告诉你) - jarno
我的版本是4.4.0-98。 - lippman27
linux-headers-generic 可能需要安装错误的头文件,至少在我的情况下是这样的。最好直接写出您的内核版本 -> linux-headers-4.15.0-30-generic - Roi
这真是令人发狂。我的内核没有任何头文件,一点也没有。我找不到任何有效的解决方法。内核版本是4.19.0-25-amd64。只使用amd64而没有版本号,没有任何软件包。使用整个字符串,也没有软件包。将软件包名称的第一个单词改为'linux',还是没有软件包。将'linux'改为'kernel',还是没有软件包。我已经浪费了整整一天的时间在这上面。没有任何软件包。没有任何软件包。没有任何软件包。一点也没有。为什么绝对没有人能够解释如何安装这些头文件? - undefined

这些命令对我有效。

查找 linux-headers-4.4.0-98

$ apt-cache search linux-headers-4.4.0-98
linux-headers-4.4.0-98 - Header files related to Linux kernel version 4.4.0
linux-headers-4.4.0-98-generic - Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
linux-headers-4.4.0-98-lowlatency - Linux kernel headers for version 4.4.0 on 64 bit x86 SMP

安装 linux-headers-4.4.0-98

重新安装时,请输入以下命令:

sudo apt install --reinstall linux-headers-4.4.0-98-generic

但对于我自己来说,这是一个新的包裹,所以我会使用:
$ sudo apt install linux-headers-4.4.0-98-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  linux-headers-4.4.0-98
The following NEW packages will be installed:
  linux-headers-4.4.0-98 linux-headers-4.4.0-98-generic
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 10.7 MB of archives.
After this operation, 78.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ca.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-4.4.0-98 all 4.4.0-98.121 [9,913 kB]
Get:2 http://ca.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-4.4.0-98-generic amd64 4.4.0-98.121 [793 kB]
Fetched 10.7 MB in 3s (3,463 kB/s)                  
Selecting previously unselected package linux-headers-4.4.0-98.
(Reading database ... 288111 files and directories currently installed.)
Preparing to unpack .../linux-headers-4.4.0-98_4.4.0-98.121_all.deb ...
Unpacking linux-headers-4.4.0-98 (4.4.0-98.121) ...
Selecting previously unselected package linux-headers-4.4.0-98-generic.
Preparing to unpack .../linux-headers-4.4.0-98-generic_4.4.0-98.121_amd64.deb ...
Unpacking linux-headers-4.4.0-98-generic (4.4.0-98.121) ...
Setting up linux-headers-4.4.0-98 (4.4.0-98.121) ...
Setting up linux-headers-4.4.0-98-generic (4.4.0-98.121) ...
Examining /etc/kernel/header_postinst.d.
run-parts: executing /etc/kernel/header_postinst.d/dkms 4.4.0-98-generic /boot/vmlinuz-4.4.0-98-generic

删除 linux-headers-4.4.0-98

因为这只是一个测试,我不需要它们在我的机器上:

$ sudo apt remove --purge linux-headers-4.4.0-98-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  linux-headers-4.4.0-98
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
  linux-headers-4.4.0-98-generic*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 7,431 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 314874 files and directories currently installed.)
Removing linux-headers-4.4.0-98-generic (4.4.0-98.121) ...
dpkg: warning: while removing linux-headers-4.4.0-98-generic, directory '/lib/modules/4.4.0-98-generic' not empty so not removed

清理剩下的垃圾

我看到最后一行有剩下的垃圾,所以我会手动清理它:

$ sudo rm -rf /lib/modules/4.4.0-98-generic
$ ll /lib/modules/4.4.0-98-generic
ls: cannot access '/lib/modules/4.4.0-98-generic': No such file or directory

现在 4.4.0-98 几乎被移除了。它完全被以下方式移除:
sudo apt autoremove

抱歉,它没有起作用。 - lippman27
@lippman27 你有足够的空闲空间吗?使用 df -h /boot 命令进行确认。谢谢。 - WinEunuuchs2Unix
是的,只有2%的人使用840G可用。 - lippman27

如果您有互联网连接...
运行 `software-properties-gtk`。在Ubuntu软件选项卡中,注意下载来源字段。那里是什么?(我使用“ubuntu.trumpetti.atm.tut.fi/ubuntu”因为我住在芬兰;至少该服务器目前有linux-headers-4.4.0-98)。尝试更改字段中的设置。在更新选项卡中,看看是否选择了“重要的安全更新”。按照对话框的指示操作。然后关闭它。然后在终端中执行以下操作(如果发生错误,请停止并请在评论中报告):
sudo apt install --reinstall linux-headers-4.4.0-98
sudo apt-mark auto linux-headers-4.4.0-98
sudo apt install linux-generic

运行 update-manager 安装更多更新。

如果您没有互联网连接...

如果问题是您没有互联网连接,但您有Ubuntu CD-ROM/DVD安装介质,您可以将其用作软件源,参见此处。如果您没有光盘介质,而是使用USB,请尝试此处

检查介质中是否包含其他内核:

apt-cache policy linux-generic

如果它包含不同版本,最好清除4.4.0-98的头文件。
sudo dpkg --purge --force-remove-reinstreq linux-headers-4.4.0-98 linux-headers-4.4.0-98-generic

从媒体上安装内核:
sudo apt install linux-generic

最后清除旧的内核镜像:
sudo apt purge linux-image-4.4.0-98-generic

运行software-properties-gtk后,应用程序停止,并且可用软件的信息已过时,但我没有互联网连接,这是我面临的另一个问题。 - lippman27
@lippman27 我更新了我的回答。 - jarno

尝试了上述许多选项后(也许有所帮助),我尝试了以下命令,它起作用了:
sudo apt --fix-broken install

我希望它对其他人有效...

已经有其他更完整的答案了。 - ChanganAuto

  • 相关问题