Vagrant use KVM provider

In this tutorial, I’ll guide you on installing and running Vagrant use KVM provider. Whether you’re a DevOps professional, coder, or sysadmin, Vagrant proves invaluable. I’ll walk you through the installation and setup process on my Fedora 32 laptop. Together, we’ll explore the seamless integration of Vagrant with the Qemu-KVM provider, opening up new possibilities for efficient development environments. Let’s dive into the steps to harness the power of Vagrant and enhance your workflow on Fedora 32.

Installing and running Vagrant use KVM provider

Check the machine supports virtualization

[HuuPV@DevopsRoles ~]$ sudo lscpu | grep Virtualization
Virtualization:                  VT-x

Install qemu-kvm

[HuuPV@DevopsRoles ~]$ sudo dnf install qemu-kvm libvirt libguestfs-tools virt-install rsync
[HuuPV@DevopsRoles ~]$ sudo systemctl enable --now libvirtd

Install Vagrant and vagrant libvirtd plugin

[HuuPV@DevopsRoles ~]$ sudo dnf install vagrant
[HuuPV@DevopsRoles ~]$ sudo vagrant plugin install vagrant-libvirt

Using the vagrant box command to Add a box

Link download box here

[HuuPV@DevopsRoles vagrant-test]$ vagrant box add centos/7 --provider=libvirt

==> box: Loading metadata for box 'centos/7'
    box: URL:
==> box: Adding box 'centos/7' (v2004.01) for provider: libvirt
    box: Downloading:
Download redirected to host:
    box: Calculating and comparing box checksum...
==> box: Successfully added box 'centos/7' (v2004.01) for 'libvirt'!

Test: Create a minimal Vagrantfile

$ mkdir vagrant-test
$ cd vagrant-test
$ vi Vagrantfile
# An example which also sets the amount memory and number of CPUs in Vagrantfile file

Vagrant.configure("2") do |config| = "centos/7"
  config.vm.provider :libvirt do |libvirt|
    libvirt.cpus = 1
    libvirt.memory = 1024

Start the box

vagrant up

The output is an example below:

[HuuPV@DevopsRoles vagrant-test]$ vagrant up
Bringing machine 'default' up with 'libvirt' provider...
==> default: Checking if box 'centos/7' version '2004.01' is up to date...
==> default: Uploading base box image as volume into libvirt storage...
==> default: Creating image (snapshot of base box volume).
==> default: Creating domain with the following settings...
==> default:  -- Name:              vagrant-test_default
==> default:  -- Domain type:       kvm
==> default:  -- Cpus:              1
==> default:  -- Feature:           acpi
==> default:  -- Feature:           apic
==> default:  -- Feature:           pae
==> default:  -- Memory:            1024M
==> default:  -- Management MAC:    
==> default:  -- Loader:            
==> default:  -- Nvram:             
==> default:  -- Base box:          centos/7
==> default:  -- Storage pool:      default
==> default:  -- Image:             /home/HuuPV/.local/share/libvirt/images/vagrant-test_default.img (41G)
==> default:  -- Volume Cache:      default
==> default:  -- Kernel:            
==> default:  -- Initrd:            
==> default:  -- Graphics Type:     vnc
==> default:  -- Graphics Port:     -1
==> default:  -- Graphics IP:
==> default:  -- Graphics Password: Not defined
==> default:  -- Video Type:        cirrus
==> default:  -- Video VRAM:        9216
==> default:  -- Sound Type:	
==> default:  -- Keymap:            en-us
==> default:  -- TPM Path:          
==> default:  -- INPUT:             type=mouse, bus=ps2
==> default: Creating shared folders metadata...
==> default: Starting domain.
==> default: Waiting for domain to get an IP address...
==> default: Waiting for SSH to become available...
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Configuring and enabling network interfaces...
    default: SSH address:
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Rsyncing folder: /home/HuuPV/Vagrant_VMS/vagrant-test/ => /vagrant

Connect to your new machine

vagrant ssh

The output as the example below

[HuuPV@DevopsRoles vagrant-test]$ vagrant ssh
[vagrant@localhost ~]$ hostname
[vagrant@localhost ~]$ pwd


Install and run Vagrant with Qemu-KVM for an enhanced experience. This step-by-step guide aims to be a valuable resource for your journey. Your support is appreciated. Thank you for exploring 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 to share the knowledge I have acquired. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

2 thoughts on “Vagrant use KVM provider

  1. Can we do this on a Windows OS directly? I mean by creating a folder in drive, then open a terminal in the window and change to the folder that I created to install QEMU VM and install Vagrant?

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.