Install Vagrant and VirtualBox on Fedora

Introduction

In this tutorial, How to Install Vagrant and VirtualBox on Fedora. You use Vagrant for DevOps professionals and coder sysadmin. I will be installing VirtualBox and Vagrant on My Laptop is Fedora 32.

How to Install Vagrant and VirtualBox

Check CPU has Intel VT or AMD-V Virtualization extensions

sudo lscpu | grep Virtualization

Add VirtualBox RPM repository

dnf -y install wget
wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo
mv virtualbox.repo /etc/yum.repos.d/virtualbox.repo

Install VirtualBox

[root@localhost ~]# dnf install -y VirtualBox*

The output on my terminal is below

[root@localhost ~]# dnf install -y  VirtualBox*
Last metadata expiration check: 0:06:53 ago on Mon 05 Oct 2020 09:32:56 PM +07.
Dependencies resolved.
======================================================================================================================
 Package                         Architecture      Version                                Repository             Size
======================================================================================================================
Installing:
 VirtualBox-6.1                  x86_64            6.1.14_140239_fedora32-1               virtualbox             88 M
Installing dependencies:
 SDL                             x86_64            1.2.15-43.fc32                         fedora                213 k
 annobin                         x86_64            9.27-1.fc32                            updates                98 k
 dwz                             x86_64            0.13-2.fc32                            fedora                109 k
 efi-srpm-macros                 noarch            4-4.fc32                               fedora                 22 k
 fonts-srpm-macros               noarch            2.0.3-1.fc32                           fedora                 26 k
 fpc-srpm-macros                 noarch            1.3-1.fc32                             fedora                7.6 k
 ghc-srpm-macros                 noarch            1.5.0-2.fc32                           fedora                7.7 k
 gnat-srpm-macros                noarch            4-11.fc32                              fedora                8.2 k
 go-srpm-macros                  noarch            3.0.9-1.fc32                           updates                25 k
 nim-srpm-macros                 noarch            3-2.fc32                               fedora                8.3 k
 ocaml-srpm-macros               noarch            6-2.fc32                               fedora                7.7 k
 openblas-srpm-macros            noarch            2-7.fc32                               fedora                7.2 k
 perl-srpm-macros                noarch            1-34.fc32                              fedora                8.3 k
 python-srpm-macros              noarch            3-59.fc32                              updates                17 k
 python27                        x86_64            2.7.18-2.fc32                          updates                11 M
 qt5-srpm-macros                 noarch            5.14.2-3.fc32                          updates               8.4 k
 redhat-rpm-config               noarch            150-1.fc32                             fedora                 63 k
 rust-srpm-macros                noarch            14-1.fc32                              updates               9.6 k
 tix                             x86_64            1:8.4.3-27.fc31                        fedora                246 k
 tk                              x86_64            1:8.6.10-3.fc32                        fedora                1.6 M

Transaction Summary
======================================================================================================================
Install  21 Packages

Total download size: 101 M
Installed size: 257 M
Downloading Packages:
(1/21): go-srpm-macros-3.0.9-1.fc32.noarch.rpm                                         82 kB/s |  25 kB     00:00    
(2/21): python-srpm-macros-3-59.fc32.noarch.rpm                                        49 kB/s |  17 kB     00:00    
(3/21): qt5-srpm-macros-5.14.2-3.fc32.noarch.rpm                                      130 kB/s | 8.4 kB     00:00    
(4/21): annobin-9.27-1.fc32.x86_64.rpm                                                210 kB/s |  98 kB     00:00    
(5/21): rust-srpm-macros-14-1.fc32.noarch.rpm                                          75 kB/s | 9.6 kB     00:00    
(6/21): SDL-1.2.15-43.fc32.x86_64.rpm                                                 217 kB/s | 213 kB     00:00    
(7/21): efi-srpm-macros-4-4.fc32.noarch.rpm                                            72 kB/s |  22 kB     00:00    
(8/21): dwz-0.13-2.fc32.x86_64.rpm                                                     82 kB/s | 109 kB     00:01    
(9/21): fpc-srpm-macros-1.3-1.fc32.noarch.rpm                                          67 kB/s | 7.6 kB     00:00    
(10/21): fonts-srpm-macros-2.0.3-1.fc32.noarch.rpm                                    116 kB/s |  26 kB     00:00    
(11/21): ghc-srpm-macros-1.5.0-2.fc32.noarch.rpm                                       44 kB/s | 7.7 kB     00:00    
(12/21): gnat-srpm-macros-4-11.fc32.noarch.rpm                                         47 kB/s | 8.2 kB     00:00    
(13/21): nim-srpm-macros-3-2.fc32.noarch.rpm                                           40 kB/s | 8.3 kB     00:00    
(14/21): ocaml-srpm-macros-6-2.fc32.noarch.rpm                                         37 kB/s | 7.7 kB     00:00    
(15/21): python27-2.7.18-2.fc32.x86_64.rpm                                            4.8 MB/s |  11 MB     00:02    
(16/21): openblas-srpm-macros-2-7.fc32.noarch.rpm                                      35 kB/s | 7.2 kB     00:00    
(17/21): perl-srpm-macros-1-34.fc32.noarch.rpm                                         40 kB/s | 8.3 kB     00:00    
(18/21): redhat-rpm-config-150-1.fc32.noarch.rpm                                      631 kB/s |  63 kB     00:00    
(19/21): tix-8.4.3-27.fc31.x86_64.rpm                                                 866 kB/s | 246 kB     00:00    
(20/21): tk-8.6.10-3.fc32.x86_64.rpm                                                  811 kB/s | 1.6 MB     00:01    
(21/21): VirtualBox-6.1-6.1.14_140239_fedora32-1.x86_64.rpm                           5.1 MB/s |  88 MB     00:17    
----------------------------------------------------------------------------------------------------------------------
Total                                                                                 4.9 MB/s | 101 MB     00:20     
warning: /var/cache/dnf/virtualbox-a644194517384f93/packages/VirtualBox-6.1-6.1.14_140239_fedora32-1.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 98ab5139: NOKEY
Fedora 32 - x86_64 - VirtualBox                                                       945  B/s | 1.7 kB     00:01    
Importing GPG key 0x98AB5139:
 Userid     : "Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>"
 Fingerprint: 7B0F AB3A 13B9 0743 5925 D9C9 5442 2A4B 98AB 5139
 From       : https://www.virtualbox.org/download/oracle_vbox.asc
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                              1/1 
  Running scriptlet: tk-1:8.6.10-3.fc32.x86_64                                                                   1/21 
  Installing       : tk-1:8.6.10-3.fc32.x86_64                                                                   1/21 
  Installing       : tix-1:8.4.3-27.fc31.x86_64                                                                  2/21 
  Running scriptlet: tix-1:8.4.3-27.fc31.x86_64                                                                  2/21 
  Installing       : perl-srpm-macros-1-34.fc32.noarch                                                           3/21 
  Installing       : openblas-srpm-macros-2-7.fc32.noarch                                                        4/21 
  Installing       : ocaml-srpm-macros-6-2.fc32.noarch                                                           5/21 
  Installing       : nim-srpm-macros-3-2.fc32.noarch                                                             6/21 
  Installing       : gnat-srpm-macros-4-11.fc32.noarch                                                           7/21 
  Installing       : ghc-srpm-macros-1.5.0-2.fc32.noarch                                                         8/21 
  Installing       : fpc-srpm-macros-1.3-1.fc32.noarch                                                           9/21 
  Installing       : efi-srpm-macros-4-4.fc32.noarch                                                            10/21 
  Installing       : dwz-0.13-2.fc32.x86_64                                                                     11/21 
  Installing       : SDL-1.2.15-43.fc32.x86_64                                                                  12/21 
  Installing       : rust-srpm-macros-14-1.fc32.noarch                                                          13/21 
  Installing       : qt5-srpm-macros-5.14.2-3.fc32.noarch                                                       14/21 
  Installing       : annobin-9.27-1.fc32.x86_64                                                                 15/21 
  Installing       : go-srpm-macros-3.0.9-1.fc32.noarch                                                         16/21 
  Installing       : python-srpm-macros-3-59.fc32.noarch                                                        17/21 
  Installing       : fonts-srpm-macros-2.0.3-1.fc32.noarch                                                      18/21 
  Installing       : redhat-rpm-config-150-1.fc32.noarch                                                        19/21 
  Installing       : python27-2.7.18-2.fc32.x86_64                                                              20/21 
  Running scriptlet: VirtualBox-6.1-6.1.14_140239_fedora32-1.x86_64                                             21/21 
  Installing       : VirtualBox-6.1-6.1.14_140239_fedora32-1.x86_64                                             21/21 
  Running scriptlet: VirtualBox-6.1-6.1.14_140239_fedora32-1.x86_64                                             21/21 

Creating group 'vboxusers'. VM users must be member of that group!


  Verifying        : annobin-9.27-1.fc32.x86_64                                                                  1/21 
  Verifying        : go-srpm-macros-3.0.9-1.fc32.noarch                                                          2/21 
  Verifying        : python-srpm-macros-3-59.fc32.noarch                                                         3/21 
  Verifying        : python27-2.7.18-2.fc32.x86_64                                                               4/21 
  Verifying        : qt5-srpm-macros-5.14.2-3.fc32.noarch                                                        5/21 
  Verifying        : rust-srpm-macros-14-1.fc32.noarch                                                           6/21 
  Verifying        : SDL-1.2.15-43.fc32.x86_64                                                                   7/21 
  Verifying        : dwz-0.13-2.fc32.x86_64                                                                      8/21 
  Verifying        : efi-srpm-macros-4-4.fc32.noarch                                                             9/21 
  Verifying        : fonts-srpm-macros-2.0.3-1.fc32.noarch                                                      10/21 
  Verifying        : fpc-srpm-macros-1.3-1.fc32.noarch                                                          11/21 
  Verifying        : ghc-srpm-macros-1.5.0-2.fc32.noarch                                                        12/21 
  Verifying        : gnat-srpm-macros-4-11.fc32.noarch                                                          13/21 
  Verifying        : nim-srpm-macros-3-2.fc32.noarch                                                            14/21 
  Verifying        : ocaml-srpm-macros-6-2.fc32.noarch                                                          15/21 
  Verifying        : openblas-srpm-macros-2-7.fc32.noarch                                                       16/21 
  Verifying        : perl-srpm-macros-1-34.fc32.noarch                                                          17/21 
  Verifying        : redhat-rpm-config-150-1.fc32.noarch                                                        18/21 
  Verifying        : tix-1:8.4.3-27.fc31.x86_64                                                                 19/21 
  Verifying        : tk-1:8.6.10-3.fc32.x86_64                                                                  20/21 
  Verifying        : VirtualBox-6.1-6.1.14_140239_fedora32-1.x86_64                                             21/21 

Installed:
  SDL-1.2.15-43.fc32.x86_64                            VirtualBox-6.1-6.1.14_140239_fedora32-1.x86_64                
  annobin-9.27-1.fc32.x86_64                           dwz-0.13-2.fc32.x86_64                                        
  efi-srpm-macros-4-4.fc32.noarch                      fonts-srpm-macros-2.0.3-1.fc32.noarch                         
  fpc-srpm-macros-1.3-1.fc32.noarch                    ghc-srpm-macros-1.5.0-2.fc32.noarch                           
  gnat-srpm-macros-4-11.fc32.noarch                    go-srpm-macros-3.0.9-1.fc32.noarch                            
  nim-srpm-macros-3-2.fc32.noarch                      ocaml-srpm-macros-6-2.fc32.noarch                             
  openblas-srpm-macros-2-7.fc32.noarch                 perl-srpm-macros-1-34.fc32.noarch                             
  python-srpm-macros-3-59.fc32.noarch                  python27-2.7.18-2.fc32.x86_64                                 
  qt5-srpm-macros-5.14.2-3.fc32.noarch                 redhat-rpm-config-150-1.fc32.noarch                           
  rust-srpm-macros-14-1.fc32.noarch                    tix-1:8.4.3-27.fc31.x86_64                                    
  tk-1:8.6.10-3.fc32.x86_64                           

Complete!

Configure VirtualBox Drivers

/usr/lib/virtualbox/vboxdrv.sh setup

The output my terminal as below

[root@localhost ~]# /usr/lib/virtualbox/vboxdrv.sh setup
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.

Download Extension Pack

cd /tmp/
wget https://download.virtualbox.org/virtualbox/6.1.2/Oracle_VM_VirtualBox_Extension_Pack-6.1.2.vbox-extpack

Install the extension pack by clicking on the Downloaded file. The picture below

Install Vagrant and VirtualBox

Install Vagrant on Fedora

Run command on your terminal as below

dnf -y install vagrant

Test Vagrant and Virtualbox

Create a minimal Vagrantfile

$ mkdir vagrant-test
$ cd vagrant-test
$ vi Vagrantfile

An example that also sets the amount of memory and number of CPUs in the Vagrantfile file

[huupv@localhost vagrant-test]$ cat Vagrantfile 
Vagrant.configure("2") do |config|
  config.ssh.insert_key = false
  config.vm.provider :virtualbox do |vb|
    vb.memory = 256
    vb.cpus = 1
  end
  
  config.vm.define "DevopsRoles" do |server01|
    server01.vm.hostname = "DevopsRoles.com"
    server01.vm.box = "centos/7"
    #server01.vm.network :private_network, ip: "192.168.3.4"
  end
end

The output on my terminal as below

huupv@localhost vagrant-test]$ vagrant up
Bringing machine 'DevopsRoles' up with 'virtualbox' provider...
==> DevopsRoles: Box 'centos/7' could not be found. Attempting to find and install...
    DevopsRoles: Box Provider: virtualbox
    DevopsRoles: Box Version: >= 0
==> DevopsRoles: Loading metadata for box 'centos/7'
    DevopsRoles: URL: https://vagrantcloud.com/centos/7
==> DevopsRoles: Adding box 'centos/7' (v2004.01) for provider: virtualbox
    DevopsRoles: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/2004.01/providers/virtualbox.box
Download redirected to host: cloud.centos.org
    DevopsRoles: Calculating and comparing box checksum...
==> DevopsRoles: Successfully added box 'centos/7' (v2004.01) for 'virtualbox'!
==> DevopsRoles: Importing base box 'centos/7'...
==> DevopsRoles: Matching MAC address for NAT networking...
==> DevopsRoles: Checking if box 'centos/7' version '2004.01' is up to date...
==> DevopsRoles: Setting the name of the VM: vagrant-test_DevopsRoles_1601910055210_96696
==> DevopsRoles: Clearing any previously set network interfaces...
==> DevopsRoles: Preparing network interfaces based on configuration...
    DevopsRoles: Adapter 1: nat
==> DevopsRoles: Forwarding ports...
    DevopsRoles: 22 (guest) => 2222 (host) (adapter 1)
==> DevopsRoles: Running 'pre-boot' VM customizations...
==> DevopsRoles: Booting VM...
==> DevopsRoles: Waiting for machine to boot. This may take a few minutes...
    DevopsRoles: SSH address: 127.0.0.1:2222
    DevopsRoles: SSH username: vagrant
    DevopsRoles: SSH auth method: private key
==> DevopsRoles: Machine booted and ready!
==> DevopsRoles: Checking for guest additions in VM...
    DevopsRoles: No guest additions were detected on the base box for this VM! Guest
    DevopsRoles: additions are required for forwarded ports, shared folders, host only
    DevopsRoles: networking, and more. If SSH fails on this machine, please install
    DevopsRoles: the guest additions and repackage the box to continue.
    DevopsRoles: 
    DevopsRoles: This is not an error message; everything may continue to work properly,
    DevopsRoles: in which case you may ignore this message.
==> DevopsRoles: Setting hostname...
==> DevopsRoles: Rsyncing folder: /home/huupv/vagrant-test/ => /vagrant

Conclusion

You have to install and run Vagrant using VirtualBox. I hope will this your helpful. Thank you for reading the DevopsRoles page!

, ,

About HuuPV

My name is Huu. I love technology, especially Devops Skill such as Docker, vagrant, git, and so forth. I like open-sources, so I created DevopsRoles.com to share the knowledge I have acquired. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.