使用vagrant中遇到的问题

参考文章:http://blog.haohtml.com/archives/14677 教程,下面将安装过程中遇到的问题收集一下.这里使用的是centos6.4 64位的系统. VirtualBox 4.3.0

当执行 vgrant up的时候时候,提示无法启用,内容模块未载入,下面为解决办法.

[root@bogon dev]# vagrant up

VirtualBox is complaining that the kernel module is not loaded. Please
run `VBoxManage –version` or open the VirtualBox GUI to see the error
message which should contain instructions on how to fix this error.

[root@bogon dev]# VBoxManage –version
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
available for the current kernel (2.6.32-358.el6.x86_64) or it failed to
load. Please recompile the kernel module and install it by

sudo /etc/init.d/vboxdrv setup

You will not be able to start VMs until this problem is fixed.
4.3.2r90405
[root@bogon dev]# sudo /etc/init.d/vboxdrv setup
Stopping VirtualBox kernel modules [ OK ]
Recompiling VirtualBox kernel modules [FAILED]
(Look at /var/log/vbox-install.log to find out what went wrong)
[root@bogon dev]# more /var/log/vbox-install.log
Makefile:183: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and r
un Make again. Stop.
Makefile:183: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and r
un Make again. Stop.
Makefile:183: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and r
un Make again. Stop.

cd /usr/src/kernels/

[root@bogon kernels]# yum install kernel-devel gcc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Package gcc-4.4.7-3.el6.x86_64 already installed and latest version
Resolving Dependencies
–> Running transaction check
—> Package kernel-devel.x86_64 0:2.6.32-358.23.2.el6 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================
Package Arch Version Repository Size
====================================================================================================================
Installing:
kernel-devel x86_64 2.6.32-358.23.2.el6 updates 8.2 M

Transaction Summary
====================================================================================================================
Install 1 Package(s)

Total download size: 8.2 M
Installed size: 24 M
Is this ok [y/N]: y
Downloading Packages:
kernel-devel-2.6.32-358.23.2.el6.x86_64.rpm | 8.2 MB 00:20
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : kernel-devel-2.6.32-358.23.2.el6.x86_64 1/1
Verifying : kernel-devel-2.6.32-358.23.2.el6.x86_64 1/1

Installed:
kernel-devel.x86_64 0:2.6.32-358.23.2.el6

Complete!
设置环境变量KERN_DIR目录
KERN_DIR=/usr/src/kernels/2.6.32-358.23.2.el6.x86_64/
export KERN_DIR

 

重新操作一次上面的 /etc/init.d/vboxdrv setup 命令,编辑virtualBox kernel modules

[root@bogon dev]# /etc/init.d/vboxdrv setup
Stopping VirtualBox kernel modules [ OK ]
Recompiling VirtualBox kernel modules [ OK ]
Starting VirtualBox kernel modules [ OK ]

然后再执行 vagrant up # 启动环境 命令