【问题标题】:Sign virtual box modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) Centos 8 [closed]签署虚拟盒模块(vboxdrv、vboxnetflt、vboxnetadp、vboxpci)Centos 8 [关闭]
【发布时间】:2020-07-29 13:53:34
【问题描述】:

我最近开始使用 Centos 8,我安装了 VirtualBox 来管理我的虚拟机, 我遇到的问题是我的 VirtualBox 无法启动任何虚拟机,它告诉我以 root 身份执行此脚本/sbin/vboxconfig,当我运行此脚本时出现以下消息:

vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: You must sign these kernel modules before using VirtualBox:
  vboxdrv vboxnetflt vboxnetadp vboxpci
See the documenatation for your Linux distribution..
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: failed: modprobe vboxdrv failed. Please use 'dmesg' to find out why.

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.

请注意,我的安全启动已启用。 我的问题是如何在 Centos 8 中签署这些内核模块?

感谢和最好的问候, 尤尼斯。

【问题讨论】:

  • 将这个问题标记为“这个问题不符合 Stack Overflow 准则”的精英人士愿意在下面告诉我们他/她为什么这样做吗?这对我来说是一个完美的 SO 问题,我很高兴我找到了它,因为它帮助了我。愿意在版主这里留下解释说明吗?
  • 我同意你的观点,我花了好几个小时才找到这个回复并在论坛上分享,我希望有人能告诉我们他们为什么这样做。谢谢

标签: linux centos virtual-machine virtualbox centos8


【解决方案1】:

经过一番研究,我找到了解决办法。

解决方案 1:禁用安全启动。

解决方案 2:

1- 安装mokutil

sudo dnf update
sudo dnf install mokutil

2- 在新文件夹下创建 RSA 密钥。

sudo -i
mkdir /root/signed-modules
cd /root/signed-modules
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VirtualBox/"
chmod 600 MOK.priv

3- 此命令会要求您添加密码,下次重启后您需要此密码。

sudo mokutil --import MOK.der

4- 重新启动系统并出现蓝屏,选择 Enroll MOK --> Continue --> 输入以前的密码,您的系统将启动。

5- 将之前的命令放入脚本中以便稍后运行(系统更新后)

cd /root/signed-modules
vi sign-virtual-box

将以下 cmd 添加到此脚本中:

#!/bin/bash

for modfile in $(dirname $(modinfo -n vboxdrv))/*.ko; do
  echo "Signing $modfile"
  /usr/src/kernels/$(uname -r)/scripts/sign-file sha256 \
                                /root/signed-modules/MOK.priv \
                                /root/signed-modules/MOK.der "$modfile"
done

如果上述方法失败,请使用以下查找符号文件并相应地编辑脚本。

find /usr/src -name signfile

5-添加exec权限并运行脚本

chmod 700 sign-virtual-box
./sign-virtual-box 

6- 启动 VirtualBOX

modprobe vboxdrv

有关更多信息,请参阅此链接(适用于 ubuntu 用户) https://stegard.net/2016/10/virtualbox-secure-boot-ubuntu-fail/

【讨论】:

  • 最后一步:update-initramfs -u -k all && reboot
  • $ sudo cd /root/signed-modules sudo: cd: command not found $ sudo /root/signed-modules sudo: /root/signed-modules: command not found 按照推荐输入命令后由你我得到了错误。
  • @lovalim 你可以使用sudo -i 以root 用户身份登录,然后使用cd ...
  • 按照说明操作,它会启动并可能会遇到错误,这是由于签名。按照下面的链接askubuntu.com/a/996685/771371
  • 也许上面的命令“find /usr/src -name signfile”应该是“find /usr/src -name sign-file”?
【解决方案2】:

我从 virtualbox 6.0 升级到 6.1 并且 vboxconfig 运行时没有错误(或需要签署内核模块)。

【讨论】:

  • 对不起,这对我不起作用
  • 同意。在 xubuntu 上运行 virtualbox 6.1。看来我需要签一些东西
【解决方案3】:

我遵循@Younes LAB 给出的solution,但我需要更改sign-virtual-box 脚本中的sign-file 路径才能正常工作:

#!/bin/bash

for modfile in $(dirname $(modinfo -n vboxdrv))/*.ko; do
  echo "Signing $modfile"
  /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 \
                                /root/signed-modules/MOK.priv \
                                /root/signed-modules/MOK.der "$modfile"
done

我正在使用 Ubuntu 20.04.2 LTS 和 VirtualBox 6.1

【讨论】:

  • 这在我的 Ubuntu 20.04.2 上成功了。谢谢!
  • 此解决方案完美运行,无需禁用安全启动。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多