E: 包 'linux-headers-4.15.0-29-generic' 没有安装候选

E: Package 'linux-headers-4.15.0-29-generic' has no installation candidate

我正在尝试在 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 information.

我尝试 运行 sudo apt install linux-headers-generic linux-headers-4.15.0-29-generic 但出现以下错误:

Reading package lists... Done
Building dependency tree       
Reading state information... 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

更新: 这是 运行ning sudo apt install virtualbox-dkms dkms

的输出
Reading package lists... Done
Building dependency tree       
Reading state information... 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.

后问题解决了