![获取正确的 Linux 标头来运行 VirtualBox/Vagrant 时出现问题](https://linux22.com/image/943393/%E8%8E%B7%E5%8F%96%E6%AD%A3%E7%A1%AE%E7%9A%84%20Linux%20%E6%A0%87%E5%A4%B4%E6%9D%A5%E8%BF%90%E8%A1%8C%20VirtualBox%2FVagrant%20%E6%97%B6%E5%87%BA%E7%8E%B0%E9%97%AE%E9%A2%98.png)
我在 Ubuntu 上:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
内核版本:
uname -r
5.13.0-23-generic
问题是我正在尝试运行 Vagrant(vagrant up)并得到以下输出:
The provider 'virtualbox' that was requested to back the machine
'default' is reporting that it isn't usable on this system. The reason
is shown below:
VirtualBox is complaining that the kernel module is not loaded. Please
run `VBoxManage --version` or open the VirtualBox GUI to see the error
message which should contain instructions on how to fix this error.
因此,当我运行时,VBoxManage --version
我得到:
WARNING: The vboxdrv kernel module is not loaded. Either there is no
module
available for the current kernel (5.13.0-23-generic) or it failed to
load. Please recompile the kernel module and install it by
sudo /sbin/vboxconfig
You will not be able to start VMs until this problem is fixed.
6.0.24r139119
当我跑步时sudo /sbin/vboxconfigre
我得到:
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
linux-headers-generic linux-headers-5.13.0-23-generic
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
linux-headers-generic linux-headers-5.13.0-23-generic
There were problems setting up VirtualBox. To re-start the set-up process, run
/sbin/vboxconfig
as root. If your system is using EFI Secure Boot you may need to sign the
kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load
them. Please see your Linux system's documentation for more information.
所以基本上,我最终建议运行相同的命令(/sbin/vboxconfig)。
更新:根据要求,这是命令的输出dpkg -l | grep virtualbox
ii virtualbox-6.0 6.0.24-139119~Ubuntu~eoan amd64 Oracle VM VirtualBox
因此,由于 Linux 标头似乎是问题所在,我尝试如下方式下载标头:
sudo apt install linux-headers-$(uname -r)
我得到了这个:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies.
linux-headers-5.13.0-23-generic : Depends: libc6 (>= 2.34) but 2.31-0ubuntu9.2 is to be installed
E: Unable to correct problems, you have held broken packages.
因此,我看了一下,结果发现对于我的 Linux 版本,我应该运行带有版本的标头: 5.4.0.91.95
或类似
但我运行的linux-headers-5.13.0-23-generic
显然是 Linux 版本 21.10(Impish Indri)的标题,如以下链接所示:
https://pkgs.org/download/linux-headers-generic
因此,不知何故,我正在运行版本 21.10 的标题,它与我实际的 Linux 版本 20.04 的 libc6 不兼容。
我尝试更新 libc6,但是 Ubuntu 警告我这样做可能会出现很多问题,所以我没有继续这样做。
我对 Linux 还比较陌生,所以如果我说的东西没有意义的话,请原谅。
我只想让 Vagrant 运行起来,但看起来要做到这一点,我首先需要整理好很多其他东西。谢谢大家!
答案1
我去试试。您已启用 focal-proposed。坏主意。
请尝试此解决方案将软件包恢复为正常来源。请注意,您必须在 apt 固定文件中将 curse 的 precise 更改为 focal。