📜  在 LM 19.3 VM 中安装 Virtualbox Guest Addtions 时遇到问题 - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:07:43.647000             🧑  作者: Mango

在 LM 19.3 VM 中安装 Virtualbox Guest Additions 时遇到问题 - Shell-Bash

问题描述

在 Linux Mint 19.3 虚拟机中,在安装 Virtualbox Guest Additions 时遇到了问题。在运行 VBoxLinuxAdditions.run 文件时,出现了以下错误消息:

Verifying archive integrity... All good.
Uncompressing VirtualBox 6.1.18 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version 6.1.18 of VirtualBox Guest Additions...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
The missing package can be probably installed with
sudo apt-get install linux-headers-4.15.0-139-generic

Building the main Guest Additions module ...fail!
 (Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions ...done.
Installing the Window System drivers
Warning: unknown version of the X Window System installed.  Not installing
X Window System drivers.
Installing graphics libraries and desktop services components ...done.
解决方法

虽然在安装 VBoxGuestAddtions 时提示了“missing package”,但是我们可以通过查看系统日志找到更多 detail。在终端中输入以下命令,查看系统日志:

cat /var/log/vboxadd-install.log

可以看到在此文件中找到了以下 error 日志:

/tmp/vbox.0/Makefile.include.header:129: *** ERROR: Kernel configuration is invalid. include/generated/autoconf.h or include/config/auto.conf are missing. Run 'make oldconfig && make prepare' on kernel src to fix it.. Stop.

这个错误意味着 Virtualbox Guest Additions 无法构建它的核心模块,由于缺少有关内核的头文件。

这是因为缺少必要的内核头文件。解决方法是安装正确的头文件。

我们可以通过以下命令安装 linux-headers(注意:将 version-number 替换为系统中的实际内核版本):

sudo apt-get install linux-headers-version-number

执行完毕后,再次尝试安装 Virtualbox Guest Additions。成功安装后,我们可以通过以下命令在 Linux Mint 中检查 Virtualbox Guest Additions 是否正确安装:

lsmod | grep vboxguest

如果返回 vboxguest 等字符串,则说明 Virtualbox Guest Additions 已正确安装。

总结

此问题的解决方法比较简单,只需要安装正确的内核头文件即可。因为是在 Linux Mint 虚拟机中出现的,所以可能会与该系统版本有关。在实际使用中,如果出现类似问题,需要根据实际情况进行相应调整。