虚拟机Virtualbox -1908问题处理总结

虚拟机安装中和因为ubuntu内核升级后可能出现的高概率错误及解决方法总结

 

这是我内核更新到5.3.0-51-generic,而virtualbox是5.2.34,产生了这个问题

虚拟机Virtualbox -1908问题处理总结_第1张图片

虚拟机Virtualbox -1908问题处理总结_第2张图片

处理过程:

VirtualBox Linux内核驱动程序( vboxdrv )未加载,或者/dev/vboxdrv存在权限问题。安装virtualbox-dkms软件包并通过执行来加载内核模块

 
modprobe vboxdrv

软件包跟踪Linux内核更改,并在必要时重新编译vboxdrv内核模块。

 where: suplibOsInit what: 3 VERR_VM_DRIVER_NOT_INSTALLED (-1908) - The support driver is not installed. On linux, open returned ENOENT. 

如何解决这个modprobe vboxdrv错误?

 

答案1

作为第一步,运行以下命令:

 sudo modprobe vboxdrv 

如果没有帮助,请运行以下命令:

 sudo apt update sudo apt install --reinstall linux-headers-$(uname -r) virtualbox-dkms dkms 

然后重新启动系统,并在重新启动后运行以下命令:

 sudo modprobe vboxdrv 

如果它不能工作,你必须在BIOS/UEFI中禁用安全引导,因为安全引导防止加载未签名的模块。

 

答案2

通过运行以下命令卸载virtualbox-dkms及它配置:

 sudo apt-get remove virtualbox-dkms sudo apt-get remove --purge virtualbox-dkms 

通过运行以下命令安装Linux headers和Linux image:

 sudo apt-get install -y linux-headers-amd64 linux-image-amd64 

安装virtualbox-dkms

sudo apt-get install -y virtualbox-dkms

https://www.kutu66.com//ubuntu/article_165260

 

报错信息:ERROR: could not insert 'vboxdrv': Required key not available

内核版本变更,开启了Secure Boot的电脑上模块必须注册才允许执行,解决问题的办法就是注册这些模块。

二、创建签名

openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=Descriptive name/"

三、注册模块

sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-filesha256 ./MOK.priv ./MOK.der$(modinfo -n vboxdrv)

四、注册 key 到 Secure Boot

sudomokutil --import MOK.der

五、重启电脑->enroll MOK->continue->yes->(输入密码,后续要用到)->reboot

六、运行

sudo modprobe vboxdrv



作者:天蓝_d82b
链接:https://www.jianshu.com/p/4a779b8e5aa8
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

然而我再运行 sudo modprobe vboxdrv 的时候一直报内核冲突的问题,此时已经将BIOS/UEFI中禁用安全引导(F12进入bios设置Secure Boot:OFF)

此时我有两种方法考虑,第一种回退内核版本(没成功),第二是更新virtualbox到更新的版本(我选的是最新版本)

因为使用sudo apt-get install virtualbox命令安装的版本一般不是最新的,所以去https://www.virtualbox.org/wiki/Linux_Downloads直接下载deb文件双击使用

更新后又出现了问题Kernel driver not installed (rc=-1908)-'/etc/init.d/vboxdrv setup'

 

处理过程:

出现Kernel driver not installed (rc=-1908)错误的原因是,没有编译成功供virtualbox使用的内核模块,要编译出这个模块,需要内核源代码,查看/usr/src可以知道;其次是需要编译器,linux下就是gcc,这两个都满足了,

再执行sudo /sbin/rcvboxdrv setup

我执行后编译错误:

Building the main VirtualBox module.
Error building the module:
make V=1 CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C /lib/modules/5.3.0-51-generic/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j8 modules
make[1]: 警告: 子 make 中强制 -jN: 关闭 jobserver 模式。
make -f ./scripts/Makefile.build obj=/tmp/vbox.0 need-modorder=1
  gcc -Wp,-MD,/tmp/vbox.0/linux/.SUPDrv-linux.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include  -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -Iubuntu/include  -include ./include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -include /tmp/vbox.0/include/VBox/SUPDrvMangling.h -fno-omit-frame-pointer -fno-pie -Wno-declaration-after-statement -I./include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -DVBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV -DIPRT_WITHOUT_EFLAGS_AC_PRESERVING -DVBOX_WITH_64_BITS_GUESTS -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64  -DMODULE  -DKBUILD_BASENAME='"SUPDrv_linux"' -DKBUILD_MODNAME='"vboxdrv"' -c -o /tmp/vbox.0/linux/SUPDrv-linux.o /tmp/vbox.0/linux/SUPDrv-linux.c
  gcc -Wp,-MD,/tmp/vbox.0/.SUPDrv.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include  -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -Iubuntu/include  -include ./include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -include /tmp/vbox.0/include/VBox/SUPDrvMangling.h -fno-omit-frame-pointer -fno-pie -Wno-declaration-after-statement -I./include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -DVBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV -DIPRT_WITHOUT_EFLAGS_AC_PRESERVING -DVBOX_WITH_64_BITS_GUESTS -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64  -DMODULE  -DKBUILD_BASENAME='"SUPDrv"' -DKBUILD_MODNAME='"vboxdrv"' -c -o /tmp/vbox.0/SUPDrv.o /tmp/vbox.0/SUPDrv.c
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
scripts/Makefile.build:288: recipe for target '/tmp/vbox.0/linux/SUPDrv-linux.o' failed
make[2]: *** [/tmp/vbox.0/linux/SUPDrv-linux.o] Error 1
make[2]: *** 正在等待未完成的任务....
  gcc -Wp,-MD,/tmp/vbox.0/.SUPDrvGip.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include  -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -Iubuntu/include  -include ./include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -include /tmp/vbox.0/include/VBox/SUPDrvMangling.h -fno-omit-frame-pointer -fno-pie -Wno-declaration-after-statement -I./include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -DVBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV -DIPRT_WITHOUT_EFLAGS_AC_PRESERVING -DVBOX_WITH_64_BITS_GUESTS -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64  -DMODULE  -DKBUILD_BASENAME='"SUPDrvGip"' -DKBUILD_MODNAME='"vboxdrv"' -c -o /tmp/vbox.0/SUPDrvGip.o /tmp/vbox.0/SUPDrvGip.c
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
scripts/Makefile.build:288: recipe for target '/tmp/vbox.0/SUPDrv.o' failed
make[2]: *** [/tmp/vbox.0/SUPDrv.o] Error 1
  gcc -Wp,-MD,/tmp/vbox.0/.SUPDrvSem.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include  -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -Iubuntu/include  -include ./include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -include /tmp/vbox.0/include/VBox/SUPDrvMangling.h -fno-omit-frame-pointer -fno-pie -Wno-declaration-after-statement -I./include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -DVBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV -DIPRT_WITHOUT_EFLAGS_AC_PRESERVING -DVBOX_WITH_64_BITS_GUESTS -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64  -DMODULE  -DKBUILD_BASENAME='"SUPDrvSem"' -DKBUILD_MODNAME='"vboxdrv"' -c -o /tmp/vbox.0/SUPDrvSem.o /tmp/vbox.0/SUPDrvSem.c
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
scripts/Makefile.build:288: recipe for target '/tmp/vbox.0/SUPDrvGip.o' failed
make[2]: *** [/tmp/vbox.0/SUPDrvGip.o] Error 1
  gcc -Wp,-MD,/tmp/vbox.0/.SUPDrvTracer.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include  -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -Iubuntu/include  -include ./include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -include /tmp/vbox.0/include/VBox/SUPDrvMangling.h -fno-omit-frame-pointer -fno-pie -Wno-declaration-after-statement -I./include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -DVBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV -DIPRT_WITHOUT_EFLAGS_AC_PRESERVING -DVBOX_WITH_64_BITS_GUESTS -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64  -DMODULE  -DKBUILD_BASENAME='"SUPDrvTracer"' -DKBUILD_MODNAME='"vboxdrv"' -c -o /tmp/vbox.0/SUPDrvTracer.o /tmp/vbox.0/SUPDrvTracer.c
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
scripts/Makefile.build:288: recipe for target '/tmp/vbox.0/SUPDrvSem.o' failed
make[2]: *** [/tmp/vbox.0/SUPDrvSem.o] Error 1
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
scripts/Makefile.build:288: recipe for target '/tmp/vbox.0/SUPDrvTracer.o' failed
make[2]: *** [/tmp/vbox.0/SUPDrvTracer.o] Error 1
Makefile:1656: recipe for target '_module_/tmp/vbox.0' failed
make[1]: *** [_module_/tmp/vbox.0] Error 2
/tmp/vbox.0/Makefile-footer.gmk:114: recipe for target 'vboxdrv' failed
make: *** [vboxdrv] Error 2

里面的4.8因当表示的是gcc 的版本,而‘-fstack-protector-strong’选项是gcc4.9以后的版本才加入的,也就是说需要安装gcc4.9以后的版本才可以编译通过

查看安装的gcc:ls /usr/bin/gcc*

 

查看当前gcc的版本:gcc -v

 

更改gcc:

vim ~/.bashrc

新增以下内容

alias gcc='/usr/bin/gcc-5'

alias g++='/usr/bin/g++-5'

使修改生效

source ~/.bashrc

PS:我执行gcc  -v发现成功修改,但是仍然报错,log中显示的是4.8,这个持保留观点,百度得其他修改方式

一直没成功,最后直接把选项-fstack-protector-strong’给注释掉了,运行sudo /sbin/rcvboxdrv setup成功编译

1.进入 /usr/src/linux-headers-5.3.0-510-generic(当前内核)

2.step2:把框框内的语句用 “#” 注释掉

虚拟机Virtualbox -1908问题处理总结_第3张图片

 

 

你可能感兴趣的:(虚拟机Virtualbox -1908问题处理总结)