解决“无法更改设备/dev/vboxdrv的组vboxusers” Virtualbox错误

时间:2020-03-21 11:47:15  来源:igfitidea点击:

从Virtualbox启动Ubuntu VM时,立即遇到以下两个错误。

错误消息框1:

Failed to open a session for the virtual machine Ubuntu 18.04 LTS Server.
Details:
The virtual machine 'Ubuntu 18.04 LTS Server' has terminated unexpectedly during startup with exit code 1 (0x1).
结果代码:ns_error_failure(0x80004005)
组件:machinewrap
界面:imachine {85632C68-B5BB-4316-A900-5EB28D3413DF}

错误消息框2:

Kernel driver not installed (rc=-1908)
The VirtualBox Linux kernel driver is either not loaded or not set up correctly. Please try setting it up again by executing
'/sbin/vboxconfig'
as root.
If your system has EFI Secure Boot enabled you Jan also 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.
where: suplibOsInit what: 3 VERR_VM_DRIVER_NOT_INSTALLED (-1908) - The support driver is not installed. On linux, open returned ENOENT.

阅读以上错误消息后,我运行了第二个错误消息框中建议的命令。

$sudo /sbin/vboxconfig

但这也无济于事。
我又收到一条错误消息。

vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: failed: Cannot change group vboxusers for device /dev/vboxdrv.
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 Jan 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.

谷歌快速搜索后,我发现我不小心将自己删除了,例如:vboxusers组中的当前用户。

如果遇到此错误,则可能在不知不觉中从vboxusers组中删除了当前用户或者删除了vboxusers组,或者同时删除了这两个用户。

要解决此问题,请首先使用以下命令创建vboxusers组:

$sudo groupadd vboxusers

然后将当前用户添加到上述组中:

$sudo usermod -a -G vboxusers sk

用我们当前的用户名替换sk。

检查是否将用户添加到组中:

$grep vboxusers /etc/group
vboxusers:x:1001:sk

是的,用户sk已添加到vboxusers的组中。

最后,使用以下命令重新启动virtualbox内核模块:

$sudo /sbin/vboxconfig

或者,

$sudo modprobe vboxdrv

或者,

$sudo /sbin/rcvboxdrv setup

现在,我可以从Virtualbox启动所有虚拟机了。
如果虚拟机仍然无法启动,请注销并重新登录。
它们应该有效!