Fedora 19更新内核导致VirtualBox无法启动

Submitted by Dot on Mon, 08/19/2013 - 22:29

简述

把对应内核版本号的模块装一遍

[[email protected] Dotcra]# yum install kmod-VirtualBox-`uname -r`

然后执行如下指令即可解决问题

[[email protected] Dotcra]# systemctl restart systemd-modules-load.service

安装DKMS以便日后自动升级

[[email protected] Dotcra]# yum install dkms

 

详细

3.10.6-200.fc19.x86_64更新至3.10.7-200.fc19.x86_64后打开VirtualBox尝试运行任一台虚拟机都会报错:

Failed to open a session for the virtual machine XXX. The virtual machine 'XXX' has terminated unexpectedly during startup with exit code 1.

VirtualBox-error-after-kernelupdates-1

Kernel driver not installed (rc=-1908) The VirtualBox Linux kernel driver (vboxdrv) is probably not loaded.

VirtualBox-error-after-kernelupdates-2 

根据图2指示,尝试运行命令却失败:

[[email protected] Dotcra]# systemctl restart systemd-modules-load.service
Job for systemd-modules-load.service failed. See 'systemctl status systemd-modules-load.service' and 'journalctl -xn' for details.
[[email protected] Dotcra]# systemctl status systemd-modules-load.service
systemd-modules-load.service - Load Kernel Modules
Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service; static)
Active: failed (Result: exit-code) since Tue 2013-08-20 09:44:05 CST; 11min ago
Docs: man:systemd-modules-load.service(8)
man:modules-load.d(5)
Process: 2382 ExecStart=/usr/lib/systemd/systemd-modules-load (code=exited, status=1/FAILURE)
Aug 20 09:44:05 Emma systemd[1]: Starting Load Kernel Modules...
Aug 20 09:44:05 Emma systemd[1]: systemd-modules-load.service: main process exited, code=exited, status=1/FAILURE
Aug 20 09:44:05 Emma systemd[1]: Failed to start Load Kernel Modules.
Aug 20 09:44:05 Emma systemd[1]: Unit systemd-modules-load.service entered failed state.
[[email protected] Dotcra]# journalctl -xn
-- Logs begin at Mon 2013-08-12 19:45:53 CST, end at Tue 2013-08-20 09:54:51 CST. --
Aug 20 09:47:54 Emma gnome-session[1308]: (gnome-settings-daemon:1495): keyboard-plugin-WARNING **: Couldn't upload new XKB keyboard description
Aug 20 09:48:53 Emma dbus-daemon[533]: dbus[533]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service'
Aug 20 09:48:53 Emma dbus[533]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service'
Aug 20 09:48:53 Emma dbus[533]: [system] Successfully activated service 'org.freedesktop.hostname1'
Aug 20 09:48:53 Emma dbus-daemon[533]: dbus[533]: [system] Successfully activated service 'org.freedesktop.hostname1'
Aug 20 09:48:53 Emma systemd[1]: Starting Hostname Service...
-- Subject: Unit systemd-hostnamed.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-hostnamed.service has begun starting up.
Aug 20 09:48:53 Emma systemd[1]: Started Hostname Service.
-- Subject: Unit systemd-hostnamed.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-hostnamed.service has finished starting up.
--
-- The start-up result is done.
Aug 20 09:53:22 Emma gnome-session[1308]: (gnome-settings-daemon:1495): keyboard-plugin-WARNING **: Couldn't upload new XKB keyboard description
Aug 20 09:54:08 Emma gnome-session[1308]: Window manager warning: Invalid WM_TRANSIENT_FOR window 0x1a00005 specified for 0x1a00003 (VirtualBox).
Aug 20 09:54:51 Emma gnome-session[1308]: (gnome-settings-daemon:1495): keyboard-plugin-WARNING **: Couldn't upload new XKB keyboard description

解决方法:

其实很简单,如果你仔细观察了YUM的过程,就会很容易理解。

[[email protected] Dotcra]# yum install VirtualBox
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package VirtualBox.x86_64 0:4.2.16-1.fc19 will be installed
--> Processing Dependency: VirtualBox-kmod = 4.2.16 for package: VirtualBox-4.2.16-1.fc19.x86_64
--> Running transaction check
---> Package kmod-VirtualBox-3.10.6-200.fc19.x86_64.x86_64 0:4.2.16-1.fc19.6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================================================================================
Installing:
VirtualBox x86_64 4.2.16-1.fc19 rpmfusion-free-updates 26 M
Installing for dependencies:
kmod-VirtualBox-3.10.6-200.fc19.x86_64 x86_64 4.2.16-1.fc19.6 rpmfusion-free-updates 203 k
Transaction Summary
==========================================================================================================================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 26 M
Installed size: 79 M

VirtualBox依赖于kmod-VirtualBox,后者其实就是模块,必须一起安装,且要选择和内核一致的版本号。 安装完后执行如下命令

[[email protected] ~]$ rpm -ql kmod-VirtualBox-3.10.6-200.fc19.x86_64
/usr/lib/modules/3.10.6-200.fc19.x86_64/extra
/usr/lib/modules/3.10.6-200.fc19.x86_64/extra/VirtualBox
/usr/lib/modules/3.10.6-200.fc19.x86_64/extra/VirtualBox/vboxdrv.ko
/usr/lib/modules/3.10.6-200.fc19.x86_64/extra/VirtualBox/vboxguest.ko
/usr/lib/modules/3.10.6-200.fc19.x86_64/extra/VirtualBox/vboxnetadp.ko
/usr/lib/modules/3.10.6-200.fc19.x86_64/extra/VirtualBox/vboxnetflt.ko
/usr/lib/modules/3.10.6-200.fc19.x86_64/extra/VirtualBox/vboxpci.ko
/usr/lib/modules/3.10.6-200.fc19.x86_64/extra/VirtualBox/vboxsf.ko
/usr/lib/modules/3.10.6-200.fc19.x86_64/extra/VirtualBox/vboxvideo.ko

可以看到kmod-VirtualBox的模块文件都被写入/usr/lib/modules/3.10.6-200.fc19.x86_64/extra/VirtualBox/,是对应内核版本号的。 很明显,每个内核都在/usr/lib/modules/下都有个以相应版本号命名的目录

[[email protected] ~]$ ls /usr/lib/modules/
3.10.6-200.fc19.x86_64 3.10.7-200.fc19.x86_64

其下的extra/VirtualBox/就是VirtualBox模块

[[email protected] ~]$ ls /usr/lib/modules/3.10.6-200.fc19.x86_64/extra/VirtualBox/
vboxdrv.ko vboxnetadp.ko vboxpci.ko vboxvideo.ko
vboxguest.ko vboxnetflt.ko vboxsf.ko

当内核更新至3.10.7-200.fc19.x86_64后,启动VirtualBox时程序就会在/lib/modules/3.10.7-200.fc19.x86_64/extra/里寻找模块,然而我们并没有安装3.10.7的模块,所以文件不存在

[[email protected] ~]$ ls /usr/lib/modules/3.10.7-200.fc19.x86_64/extra/VirtualBox/
ls: cannot access /usr/lib/modules/3.10.7-200.fc19.x86_64/extra/VirtualBox/: No such file or directory

程序找不到,自然要报错。 所以此时把3.10.7的模块安装一遍

[[email protected] Dotcra]# yum install kmod-VirtualBox-3.10.7-200.fc19.x86_64.x86_64

然后重新执行如下指令

[[email protected] Dotcra]# systemctl restart systemd-modules-load.service

再无报错,问题解决。

但Linux内核更新是经常的事,我们当然不希望每次都重新为Virtualbox手动安装模块。所以DKMS是必须的,它会在系统内核更新后自动重建内核模块。

Virtualbox官方文档中做了相关介绍,参见2.3.2. The VirtualBox kernel module https://www.virtualbox.org/manual/ch02.html#externalkernelmodules

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.