Centos 8 签名虚拟框模块(vboxdrv、vboxnetflt、vboxnetadp、vboxpci)

You*_*You 10 linux virtualbox centos virtual-machine centos8

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

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.
Run Code Online (Sandbox Code Playgroud)

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

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

Bea*_*eca 18

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

#!/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
Run Code Online (Sandbox Code Playgroud)

我正在使用 Ubuntu 20.04.2 LTS 和 VirtualBox 6.1

  • 这在我的 Ubuntu 20.04.2 上成功了。谢谢! (3认同)
  • 该解决方案完美运行,无需禁用安全启动。 (3认同)

You*_*You 8

经过一番研究,我找到了解决方案。

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

解决方案2:

1-安装mokutil

sudo dnf update
sudo dnf install mokutil
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

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

sudo mokutil --import MOK.der
Run Code Online (Sandbox Code Playgroud)

4- 重新启动系统并出现蓝屏,选择注册 MOK --> 继续 --> 输入以前的密码,系统将启动。

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

cd /root/signed-modules
vi sign-virtual-box
Run Code Online (Sandbox Code Playgroud)

将以下 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
Run Code Online (Sandbox Code Playgroud)

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

find /usr/src -name signfile
Run Code Online (Sandbox Code Playgroud)

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

chmod 700 sign-virtual-box
./sign-virtual-box 
Run Code Online (Sandbox Code Playgroud)

6- 启动 VirtualBOx

modprobe vboxdrv
Run Code Online (Sandbox Code Playgroud)

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

  • 最后一步:update-initramfs -u -k all && restart (2认同)
  • 也许上面的命令“find /usr/src -name signfile”应该是“find /usr/src -name sign-file”? (2认同)