在 CentOS 7 上安装 VirtualBox 时,服务 vboxdrv 设置抛出错误

在 CentOS 7 上安装 VirtualBox 时,服务 vboxdrv 设置抛出错误

我正在尝试在最小(仅限终端)CentOS 7 服务器上安装 VirtualBox 5.0,但当我键入时不断收到以下错误service vboxdrv setup

The service command supports only basic LSB actions (start, stop,  
restart, try-restart, reload, force-reload, status). For other  
actions, please try to use systemctl.

导致错误的步骤:


导致错误的完整步骤如下:

vi /etc/yum.repos.d/virtualbox.repo

添加以下文本,然后保存并退出:

[virtualbox]
name=Oracle Linux / RHEL / CentOS-$releasever / $basearch – VirtualBox
baseurl=http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch
enabled=1
gpgcheck=1
gpgkey=http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc

然后在命令提示符下键入:

# rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
# yum install gcc make patch  dkms qt libgomp 
# yum install kernel-headers kernel-devel fontforge binutils glibc-headers glibc-devel
...
Complete!  
# cd /usr/src/kernels
# ls –al
total 12
drwxr-xr-x.  3 root root 4096 Sep 25 16:14 .
drwxr-xr-x.  4 root root 4096 Sep 25 14:17 ..
drwxr-xr-x. 22 root root 4096 Sep 25 16:14 3.10.0-229.14.1.el7.x86_64
# export KERN_DIR=/usr/src/kernels/3.10.0-229.14.1.el7.x86_64
# yum install VirtualBox-5.0
...
Complete!  
#  yum install "kernel-devel-uname-r == $(uname -r)"
#  setenforce Permissive
# service vboxdrv setup
The service command supports only basic LSB actions (start, stop,  
restart, try-restart, reload, force-reload, status). For other  
actions, please try to use systemctl.

请注意,当我以已添加到vboxusers组中的非 root 用户身份运行该命令时,会出现相同的错误。

我该如何解决这个错误?

根据@MarkPlotnick的建议,我尝试了以下操作,但得到了不同的错误:

[root@localhost kernels]# /etc/init.d/vboxdrv setup
-bash: /etc/init.d/vboxdrv: No such file or directory
[root@localhost kernels]# -I /etc/init.d/vboxdrv setup
-bash: -I: command not found
[root@localhost kernels]# cd /etc/init.d
[root@localhost init.d]# ls -al
total 40
drwxr-xr-x.  2 root root  4096 Oct  2 12:32 .
drwxr-xr-x. 10 root root  4096 Oct  2 12:32 ..
-rw-r--r--.  1 root root 13430 Jan 15  2015 functions
-rwxr-xr-x.  1 root root  2989 Jan 15  2015 netconsole
-rwxr-xr-x.  1 root root  6470 Jan 15  2015 network
-rw-r--r--.  1 root root  1160 Sep 15 06:21 README
[root@localhost init.d]# 

答案1

可能的解决方案:/usr/lib/virtualbox/vboxdrv.sh setup

这个问题似乎是在最新的 VirtualBox-5.0-5.0.6_103037_el7 安装/更新中出现的(这是 5.0.4 -> 5.0.6 的 yum 更新的一部分:

Cleanup    : VirtualBox-5.0-5.0.4_102546_el7-1.x86_64                                                                                       18/18 
warning: file /etc/rc.d/init.d/vboxweb-service: remove failed: No such file or directory

warning: file /etc/rc.d/init.d/vboxdrv: remove failed: No such file or directory

warning: file /etc/rc.d/init.d/vboxballoonctrl-service: remove failed: No such file or directory

warning: file /etc/rc.d/init.d/vboxautostart-service: remove failed: No such file or directory

相关内容