![使用 dkms 的 VirtualBox 模块失败,因为没有最新内核的标头](https://linux22.com/image/1149159/%E4%BD%BF%E7%94%A8%20dkms%20%E7%9A%84%20VirtualBox%20%E6%A8%A1%E5%9D%97%E5%A4%B1%E8%B4%A5%EF%BC%8C%E5%9B%A0%E4%B8%BA%E6%B2%A1%E6%9C%89%E6%9C%80%E6%96%B0%E5%86%85%E6%A0%B8%E7%9A%84%E6%A0%87%E5%A4%B4.png)
由于 Firefox 4.10 存在问题,我刚刚升级到 4.12.0-041200.-generic 内核。我正在运行 17.04。
我这样做了:
$ sudo apt-get --reinstall install virtualbox-dkms
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.10.0-26 linux-headers-4.10.0-26-generic linux-image-4.10.0-26-generic linux-image-extra-4.10.0-26-generic linux-signed-image-4.10.0-26-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/641 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 350604 files and directories currently installed.)
Preparing to unpack .../virtualbox-dkms_5.1.22-dfsg-0ubuntu1.17.04.1_all.deb ...
------------------------------
Deleting module version: 5.1.22
completely from the DKMS tree.
------------------------------
Done.
Unpacking virtualbox-dkms (5.1.22-dfsg-0ubuntu1.17.04.1) over (5.1.22-dfsg-0ubuntu1.17.04.1) ...
Setting up virtualbox-dkms (5.1.22-dfsg-0ubuntu1.17.04.1) ...
Loading new virtualbox-5.1.22 DKMS files...
Building for 4.12.0-041200-generic
Building initial module for 4.12.0-041200-generic
ERROR (dkms apport): kernel package linux-headers-4.12.0-041200-generic is not supported
Error! Bad return status for module build on kernel: 4.12.0-041200-generic (x86_64)
Consult /var/lib/dkms/virtualbox/5.1.22/build/make.log for more information.
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; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2017-07-29 11:04:34 PDT; 5ms ago
Docs: man:systemd-sysv-generator(8)
Process: 16149 ExecStart=/etc/init.d/virtualbox start (code=exited, status=1/FAILURE)
Jul 29 11:04:34 dabbers systemd[1]: Starting LSB: VirtualBox Linux kernel module...
Jul 29 11:04:34 dabbers virtualbox[16149]: * Loading VirtualBox kernel modules...
Jul 29 11:04:34 dabbers virtualbox[16149]: * No suitable module for running kernel found
Jul 29 11:04:34 dabbers virtualbox[16149]: ...fail!
Jul 29 11:04:34 dabbers systemd[1]: virtualbox.service: Control process exited, code=exited status=1
Jul 29 11:04:34 dabbers systemd[1]: Failed to start LSB: VirtualBox Linux kernel module.
Jul 29 11:04:34 dabbers systemd[1]: virtualbox.service: Unit entered failed state.
Jul 29 11:04:34 dabbers systemd[1]: virtualbox.service: Failed with result 'exit-code'.
$more make.log
DKMS make.log for virtualbox-5.1.22 for kernel 4.12.0-041200-generic (x86_64)
Sat Jul 29 11:04:30 PDT 2017
make: Entering directory '/usr/src/linux-headers-4.12.0-041200-generic'
LD /var/lib/dkms/virtualbox/5.1.22/build/built-in.o
LD /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/built-in.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/linux/SUPDrv-linux.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/SUPDrv.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/SUPDrvGip.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/SUPDrvSem.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/SUPDrvTracer.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/SUPLibAll.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/alloc-r0drv.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/initterm-r0drv.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/memobj-r0drv.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/mpnotification-r0drv.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/powernotification-r0drv.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/assert-r0drv-linux.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/alloc-r0drv-linux.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/initterm-r0drv-linux.o
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.o
In file included from /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/alloc-r0drv-linux.c:31:0:
/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/alloc-r0drv-linux.c: In function ‘VBoxHost_RTMemContAlloc’:
/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/the-linux-kernel.h:323:47: error: implicit declaration of function ‘set_pages_x’ [-Werror=implicit-function-declar
ation]
# define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
^
/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/alloc-r0drv-linux.c:445:13: note: in expansion of macro ‘MY_SET_PAGES_EXEC’
MY_SET_PAGES_EXEC(&paPages[iPage], 1);
^~~~~~~~~~~~~~~~~
/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/alloc-r0drv-linux.c: In function ‘VBoxHost_RTMemContFree’:
/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/the-linux-kernel.h:324:47: error: implicit declaration of function ‘set_pages_nx’ [-Werror=implicit-function-decla
ration]
# define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
^
/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/alloc-r0drv-linux.c:493:13: note: in expansion of macro ‘MY_SET_PAGES_NOEXEC’
MY_SET_PAGES_NOEXEC(&paPages[iPage], 1);
^~~~~~~~~~~~~~~~~~~
CC [M] /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/memuserkernel-r0drv-linux.o
cc1: some warnings being treated as errors
scripts/Makefile.build:302: recipe for target '/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/alloc-r0drv-linux.o' failed
make[2]: *** [/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/alloc-r0drv-linux.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.c: In function ‘rtR0MemObjLinuxVirtToPage’:
/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.c:922:27: error: passing argument 1 of ‘pud_offset’ from incompatible pointer type [-Werror=inc
ompatible-pointer-types]
u.Upper = *pud_offset(&u.Global, ulAddr);
^
In file included from ./include/linux/mm.h:70:0,
from /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/the-linux-kernel.h:98,
from /var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.c:31:
./arch/x86/include/asm/pgtable.h:826:22: note: expected ‘p4d_t * {aka struct <anonymous> *}’ but argument is of type ‘pgd_t * {aka struct <anonymous> *}’
static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
^~~~~~~~~~
cc1: some warnings being treated as errors
scripts/Makefile.build:302: recipe for target '/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.o' failed
make[2]: *** [/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.o] Error 1
scripts/Makefile.build:561: recipe for target '/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv' failed
make[1]: *** [/var/lib/dkms/virtualbox/5.1.22/build/vboxdrv] Error 2
Makefile:1512: recipe for target '_module_/var/lib/dkms/virtualbox/5.1.22/build' failed
make: *** [_module_/var/lib/dkms/virtualbox/5.1.22/build] Error 2
make: Leaving directory '/usr/src/linux-headers-4.12.0-041200-generic'
答案1
这个问题是关于记忆驱动的。我希望修补因为 virtualbox 会帮助你。