Skip to content

Instantly share code, notes, and snippets.

@thieryl
Created July 20, 2018 11:12
Show Gist options
  • Save thieryl/21accbe279135782e9330c533df6b5a6 to your computer and use it in GitHub Desktop.
Save thieryl/21accbe279135782e9330c533df6b5a6 to your computer and use it in GitHub Desktop.
[Vagrant] Vagrant and Virtualbox Installation on Fedora #linux

Vagrant and Virtualbox Installation on Fedora

This article explains how to install Vagrant and Virtualbox on Fedora 23/24 so you can build your development environments. Vagrant and Virtualbox provide an easy way to create, configure and distribute development environments.

This play is also working on the brand new Fedora 26 with just a glitch about few missing headers files, see my note at the end.

VirtualBox Installation Add VirtualBox repository and update your system:

$ sudo su -
# cd /etc/yum.repos.d/
# wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo
# dnf update

Ensure that you are running latest installed kernel version, you can check it by comparing the output of following commands, version numbers should match:

# rpm -qa kernel |sort -V |tail -n 1
# uname -r

If you got a kernel update then reboot your system.

Install VirtualBox dependencies:

# dnf install binutils gcc make patch libgomp glibc-headers \
  glibc-devel kernel-headers kernel-devel dkms

# dnf install VirtualBox Last command will build needed kernel modules, in case you need in the future to rebuild them, you can use the following command:

In order to use VirtualBox, a user must be member of vboxusers group which was created automatically during Virtualbox installation. Add your username to vboxusers group

# usermod -a -G vboxusers username

Vagrant Installation

Run the following commands to install Vagrant:

$ sudo dnf install vagrant

Note that Fedora use libvirt as default provider, so to use Virtualbox instead you need to set an environment variable for it. Run the following commands:

$ echo "export VAGRANT_DEFAULT_PROVIDER=virtualbox" >> ~/.bashrc
If you prefer to use Vagrant with KVM, make sure to install libvirt packages for it.

$ sudo dnf install -y vagrant vagrant-libvirt libvirt-devel Finally, install some useful vagrant plugins, but before we need to install .

$ vagrant plugin install vagrant-cachier
$ vagrant plugin install vagrant-hostmanager

While installing vagrant-cachier on a brand new Fedora 24 I had some errors about missing headers, to fix it you need to install the following packages:

$ sudo dnf install ruby-devel redhat-rpm-config zlib-devel You can find more info about Gems installation in the Fedora Developer site.

Launch a Vagrant box Now you can launch a vagrant box, for example try the official CentOS 7.

$ vagrant init centos/7
$ vagrant up --provider virtualbox

if you use libvirt provider:

$ vagrant up --provider libvirt

What to do after a kernel update

launch the following command

/usr/lib/virtualbox/vboxdrv.sh setup

Add a second user

Vagrant.configure("2") do |config|
  if VAGRANT_COMMAND == "ssh"
      config.ssh.username = 'other_username'
  end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment