在Fedora 21上默认使用VirtualBox提供程序


12

现在,我使用的无业游民任何时候,它会尝试使用libvirt作为供应商。我想默认使用VirtualBox。

vagrant-libvirt 未安装。

这很麻烦,因为某些命令不起作用,例如vagrant status

[florian@localhost local]$ vagrant status
The provider 'libvirt' could not be found, but was requested to
back the machine 'foobar'. Please use a provider that exists.
[florian@localhost local]$ vagrant status --provider=virtualbox
An invalid option was specified. The help for this command
is available below.

Usage: vagrant status [name]
    -h, --help                       Print this help

我很想添加以下标签,但没有足够的声誉来创建它们:fedora-21 libvirt
Florian Margaine 2015年

我补充libvirtd了这个问题。我认为在每个特定的Fedora版本上都没有标记是没有价值的,尤其是当它们在发行后的12个月内停止运行时。
jordanm 2015年

Answers:


25

根据vagrant的文档,默认提供程序应为virtualbox,并且该VAGRANT_DEFAULT_PROVIDER变量可让您覆盖它。

但是,VAGRANT_DEFAULT_PROVIDER是空的,所以应该是virtualbox,对吗?好吧,如果我将变量设置为virtualbox,它将再次起作用。所以我猜fedora在其他地方设置了默认变量。

解:

$ echo "export VAGRANT_DEFAULT_PROVIDER=virtualbox" >> ~/.bashrc
$ source ~/.bashrc

4

这只是我遇到此问题的经验。

执行时vagrant up,我得到了

The provider 'libvirt' could not be found, but was requested to
back the machine 'default'. Please use a provider that exists.

我尝试了上面提供的命令

echo "export VAGRANT_DEFAULT_PROVIDER=virtualbox" >> ~/.bashrc
source ~/.bashrc

然后我执行 vagrant up

The provider 'virtualbox' that was requested to back the machine
'default' is reporting that it isn't usable on this system. The
reason is shown below:

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.

使用VBoxManage --version,它给了我

The vboxdrv kernel module is not loaded. Either there is no module
available for the current kernel (4.0.4-303.fc22.x86_64) or it failed to
load. Please recompile the kernel module and install it

并提示我执行sudo /etc/init.d/vboxdrv setup解决了我的问题。


2
只是virtualbox当时没有正确设置,与vagrant没有直接关系。但是,感谢您提供的信息,它可能对将来的Google员工有用!
Florian Margaine 2015年

1
@FlorianMargaine,您的回答有所帮助,我想分享我在处理此问题上的经验。
user2555595 2015年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.