Fedora

在 Fedora 21 上預設使用 VirtualBox 提供程序

  • April 5, 2019

現在,每當我使用 vagrant 時,它都會嘗試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

根據vagrant 的文件,預設提供程序應該是virtualbox,並且該VAGRANT_DEFAULT_PROVIDER變數允許您覆蓋它。

但是,VAGRANT_DEFAULT_PROVIDER是空的,所以應該是virtualbox,對吧?好吧,如果我將變數設置為virtualbox,它會再次起作用。所以我猜fedora在其他地方設置了預設變數。

解決方案:

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

這只是我遇到這個問題的經驗。

在執行時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解決了我的問題。

引用自:https://unix.stackexchange.com/questions/194691