在CentOS5下,首先下载virtualBox3.0.6,这是稳定版:
下,选择For Linux Host,
下载的文件名为:VirtualBox-3.0.6_52128_rhel5-1.i386.rpm
然后安装->无论如何都安装。就可以了。
当然,你也可以选择yum install virtualbox来安装,更省事。
但是,安装后在应用程序->系统工具->Sun Virtualbox中可以正常打开程序,但新建虚拟机后却不能运行。显示如下错误:
Kernel driver not installed (rc=-1908)
The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Re-setup the kernel module by executing
'/etc/init.d/vboxdrv setup'
as root. Users of Ubuntu, Fedora or Mandriva should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary.
执行/etc/init.d/vboxdrv setup后,出现了以下的错误:
Stopping VirtualBox kernel module [确定]Recompiling VirtualBox kernel module [失败] (Look at /var/log/vbox-install.log to find out what went wrong)然后,那咱就查看vox-install.log这个文件呗:
cat /var/log/vbox-install.log Makefile:147: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR= and run Make again。 停止。执行yum install kernel,升级内核。
开始,我还以为是没有找到系统内核,但加入内核代码后还是一样的错误。后来发现,原因在于我没有安装GCC,从而导致virtualbox不能用本地gcc编译适合它使用的内核模块,于是赶紧yum install gcc。。。。。这是一个漫长的过程:
[root@liukai mldonkey-distrib-3.0.0]# yum install gcc
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package gcc.i386 0:4.1.2-44.el5 set to be updated
--> Processing Dependency: libgomp >= 4.1.2-44.el5 for package: gcc
--> Processing Dependency: libgcc >= 4.1.2-44.el5 for package: gcc
--> Processing Dependency: cpp = 4.1.2-44.el5 for package: gcc
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc
--> Running transaction check
---> Package libgomp.i386 0:4.3.2-7.el5 set to be updated
---> Package cpp.i386 0:4.1.2-44.el5 set to be updated
---> Package glibc-devel.i386 0:2.5-34.el5_3.1 set to be updated
--> Processing Dependency: glibc-headers = 2.5-34.el5_3.1 for package: glibc-devel
--> Processing Dependency: glibc-headers for package: glibc-devel
--> Processing Dependency: glibc = 2.5-34.el5_3.1 for package: glibc-devel
---> Package libgcc.i386 0:4.1.2-44.el5 set to be updated
--> Running transaction check
---> Package glibc.i686 0:2.5-34.el5_3.1 set to be updated
--> Processing Dependency: glibc-common = 2.5-34.el5_3.1 for package: glibc
---> Package glibc-headers.i386 0:2.5-34.el5_3.1 set to be updated
--> Processing Dependency: kernel-headers for package: glibc-headers
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers
--> Running transaction check
---> Package kernel-headers.i386 0:2.6.18-164.el5 set to be updated
---> Package glibc-common.i386 0:2.5-34.el5_3.1 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
gcc i386 4.1.2-44.el5 base 5.2 M
Updating:
cpp i386 4.1.2-44.el5 base 2.7 M
glibc i686 2.5-34.el5_3.1 updates 5.2 M
glibc-common i386 2.5-34.el5_3.1 updates 16 M
libgcc i386 4.1.2-44.el5 base 94 k
Installing for dependencies:
glibc-devel i386 2.5-34.el5_3.1 updates 2.0 M
glibc-headers i386 2.5-34.el5_3.1 updates 598 k
kernel-headers i386 2.6.18-164.el5 updates 993 k
libgomp i386 4.3.2-7.el5 base 67 k
Transaction Summary
=============================================================================
Install 5 Package(s)
Update 4 Package(s)
Remove 0 Package(s)
Total download size: 33 M
Is this ok [y/N]: y
Downloading Packages:
(1/9): libgcc-4.1.2-44.el 100% |=========================| 94 kB 00:06
(2/9): glibc-devel-2.5-34 100% |=========================| 2.0 MB 09:04
(3/9): glibc-headers-2.5- 100% |=========================| 598 kB 02:33
(4/9): gcc-4.1.2-44.el5.i 100% |=========================| 5.2 MB 03:37
(5/9): cpp-4.1.2-44.el5.i 100% |=========================| 2.7 MB 02:33
(6/9): libgomp-4.3.2-7.el 100% |=========================| 67 kB 00:04
(7/9): glibc-common-2.5-3 100% |=========================| 2.7 MB 19:56
ftp://ftp.chu.edu.tw/Linux/CentOS/5.3/updates/i386/RPMS/glibc-common-2.5-34.el5_3.1.i386.rpm: [Errno 4] Socket Error: timed out
Trying other mirror.
(7/9): glibc-common-2.5-3 100% |=========================| 16 MB 27:40
(8/9): kernel-headers-2.6 100% |=========================| 993 kB 00:52
(9/9): glibc-2.5-34.el5_3 100% |=========================| 5.2 MB 04:42
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : libgcc ####################### [ 1/13]
Updating : glibc-common ####################### [ 2/13]
Updating : glibc ####################### [ 3/13]
Installing: libgomp ####################### [ 4/13]
Updating : cpp ####################### [ 5/13]
Installing: kernel-headers ####################### [ 6/13]
Installing: glibc-headers ####################### [ 7/13]
Installing: glibc-devel ####################### [ 8/13]
Installing: gcc ####################### [ 9/13]
Cleanup : glibc ####################### [10/13]
Cleanup : glibc-common ####################### [11/13]
Cleanup : cpp ####################### [12/13]
Cleanup : libgcc ####################### [13/13]
Installed: gcc.i386 0:4.1.2-44.el5
Dependency Installed: glibc-devel.i386 0:2.5-34.el5_3.1 glibc-headers.i386 0:2.5-34.el5_3.1 kernel-headers.i386 0:2.6.18-164.el5 libgomp.i386 0:4.3.2-7.el5
Updated: cpp.i386 0:4.1.2-44.el5 glibc.i686 0:2.5-34.el5_3.1 glibc-common.i386 0:2.5-34.el5_3.1 libgcc.i386 0:4.1.2-44.el5
Complete!
You have new mail in /var/spool/mail/root
然后再次重启虚拟机就可以了。如果还是不行,那就先用rpm -e卸载了刚装的virtualbox,然后再安装下,就可以了。
此外,如果你的系统是ubuntu的可以这样解决:
sudo aptitude update
sudo aptitude install dkms
sudo /etc/init.d/vboxdrv setup现在总结下:出现Kernel driver not installed (rc=-1908)错误的原因是,没
有编译成功供virtualbox使用的内核模块,要编译出这个模块,需要内核源代码,查看/usr/src可以知道;其次是需要编译器,linux下就是gcc,这两个都满足了,再执行[root@liukai ~]# /etc/init.d/vboxdrv setupStopping VirtualBox kernel module [确定]Recompiling VirtualBox kernel module [确定]Starting VirtualBox kernel module [确定]就可以了。而这个过程,希望大家都用yum来完成,以减少因依赖产成的错误。注意,需要看清楚你的内核和升级的是不是同一个,如不是还需要把old卸载,然后reboot,用新内核再vboxdrv setup。此外,如果碰到新版本的VirtualBox,比如3.1.8,或者使用了CentOS5.5系统。安原来的安装过程会出现下述错误:“Trying to register the VirtualBox kernel modules using DKMS”或者“unable to find the sources of your current Linux kernel”解决方法是:yum install kernel-devel-i686(i686使用uname -a得知)随后,export KERN_DIR=/usr/src/kernels/2.6.18-164.15.1.el5-i686/(2.6.18-164.15.1.el5-i686可查看自己机器就具体位置而知)
最后,/etc/init.d/vboxdrv setup即可。
本文原创,请转载的同志注明出处为五岳之巅博客,谢谢。