问题描述
我正在尝试在 Ubuntu 18.04 上设置 VirtualBox,但是当我尝试运行它时说:
WARNING: The vBoxdrv kernel module is not loaded. Either there is no module
available for the current kernel (4.15.0-29-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.
所以我运行了 sudo /sbin/vBoxconfig
,我得到了以下错误:
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-4.15.0-29-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-4.15.0-29-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 @R_834_4045@ion.
我尝试运行 sudo apt install linux-headers-generic linux-headers-4.15.0-29-generic
但出现以下错误:
Reading package lists... Done
Building dependency tree
Reading state @R_834_4045@ion... Done
Package linux-headers-4.15.0-29-generic is not available,but is referred to by another package.
This may mean that the package is missing,has been obsoleted,or
is only available from another source
E: Package 'linux-headers-4.15.0-29-generic' has no installation candidate
更新: 这是运行 sudo apt install virtualBox-dkms dkms
的输出Reading package lists... Done
Building dependency tree
Reading state @R_834_4045@ion... Done
dkms is already the newest version (2.3-3ubuntu9).
dkms set to manually installed.
The following packages were automatically installed and are no longer required:
kbuild libsdl-ttf2.0-0 module-assistant
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
virtualBox virtualBox-qt
Suggested packages:
vde2 virtualBox-guest-additions-iso
The following packages will be REMOVED:
virtualBox-5.1
The following NEW packages will be installed:
virtualBox virtualBox-dkms virtualBox-qt
0 upgraded,3 newly installed,1 to remove and 3 not upgraded.
Need to get 0 B/26.3 MB of archives.
After this operation,51.0 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 429944 files and directories currently installed.)
Removing virtualBox-5.1 (5.1.38-122592~Ubuntu~bionic) ...
Selecting prevIoUsly unselected package virtualBox-dkms.
(Reading database ... 429153 files and directories currently installed.)
Preparing to unpack .../virtualBox-dkms_5.2.10-dfsg-6_all.deb ...
Unpacking virtualBox-dkms (5.2.10-dfsg-6) ...
Selecting prevIoUsly unselected package virtualBox.
Preparing to unpack .../virtualBox_5.2.10-dfsg-6_amd64.deb ...
Unpacking virtualBox (5.2.10-dfsg-6) ...
Selecting prevIoUsly unselected package virtualBox-qt.
Preparing to unpack .../virtualBox-qt_5.2.10-dfsg-6_amd64.deb ...
Unpacking virtualBox-qt (5.2.10-dfsg-6) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.1) ...
Setting up virtualBox-dkms (5.2.10-dfsg-6) ...
Loading new virtualBox-5.2.10 DKMS files...
Building for 4.15.0-29-generic
Module build for kernel 4.15.0-29-generic was skipped since the
kernel headers for this kernel does not seem to be installed.
Setting up virtualBox (5.2.10-dfsg-6) ...
vBoxweb.service is a disabled or a static unit,not starting it.
Job for virtualBox.service Failed because the control process exited with error code.
See "systemctl status virtualBox.service" and "journalctl -xe" for details.
invoke-rc.d: initscript virtualBox,action "restart" Failed.
● virtualBox.service - LSB: VirtualBox Linux kernel module
Loaded: loaded (/etc/init.d/virtualBox; generated)
Active: Failed (Result: exit-code) since Sun 2021-01-24 13:24:20 IST; 10ms ago
Docs: man:systemd-sysv-generator(8)
Process: 17173 ExecStart=/etc/init.d/virtualBox start (code=exited,status=1/FAILURE)
Jan 24 13:24:19 Tux systemd[1]: Starting LSB: VirtualBox Linux kernel module...
Jan 24 13:24:19 Tux virtualBox[17173]: * Loading VirtualBox kernel modules...
Jan 24 13:24:20 Tux virtualBox[17173]: * No suitable module for running kernel found
Jan 24 13:24:20 Tux virtualBox[17173]: ...fail!
Jan 24 13:24:20 Tux systemd[1]: virtualBox.service: Control process exited,code=exited status=1
Jan 24 13:24:20 Tux systemd[1]: virtualBox.service: Failed with result 'exit-code'.
Jan 24 13:24:20 Tux systemd[1]: Failed to start LSB: VirtualBox Linux kernel module.
Processing triggers for bamfdaemon (0.5.3+18.04.20180207.2-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for systemd (237-3ubuntu10) ...
Processing triggers for man-db (2.8.3-2) ...
Processing triggers for shared-mime-info (1.9-2) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Setting up virtualBox-qt (5.2.10-dfsg-6) ...
Processing triggers for ureadahead (0.100.0-20) ...
我已关闭安全启动并在 bios 中打开虚拟化。我也尝试从 virutalBox wesite 安装 .deb 包,但仍然出现此错误。 20.04 的全新安装是我唯一还没有做的事情。
解决方法
问题在我安装 Ubuntu 20.04 后得到解决。