Skip to content
Tutorials Center
My learning

Topics

Lesson 24 of 36 ยท Providers and Plugins

Hyper-V, libvirt and VMware Providers

Use Vagrant with Hyper-V on Windows, libvirt and KVM on Linux, and VMware or Parallels on desktops: setup, settings, networking and limits of each provider.

VirtualBox covers most needs, but it is not always the best choice. Windows machines with WSL 2 or Docker Desktop often run Hyper-V already. Linux servers have KVM built into the kernel. Mac users on Apple silicon need a provider that supports ARM. This lesson shows how each alternative differs from VirtualBox so you know what to change in your Vagrantfile.

All commands and Vagrantfiles below are read-only examples: they need the real hypervisor on your own computer.

Hyper-V on Windows

Hyper-V ships with Windows Pro, Enterprise and Education. Vagrant includes the provider; you only enable the feature and run your terminal as administrator.

TEXT
PS> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
PS> vagrant up --provider=hyperv

A matching Vagrantfile:

Ruby
Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu2204"

  config.vm.provider "hyperv" do |hv|
    hv.memory = 2048
    hv.cpus = 2
    hv.maxmemory = 4096        # dynamic memory ceiling
    hv.linked_clone = true
    hv.enable_virtualization_extensions = true  # nested virtualization
  end
end

Things that differ from VirtualBox:

  • Administrator rights are required for most commands. Run PowerShell as administrator, or you will see a "Hyper-V commands must be run as administrator" error.
  • Networking. Hyper-V attaches a machine to a virtual switch (the "Default Switch" is picked automatically on newer Windows versions). private_network with a fixed IP is not honored in the same way; the guest gets an address from the switch, and you find it with vagrant ssh -c "hostname -I".
  • Synced folders. The default rsync does not work out of the box on Windows, and SMB shares prompt for your Windows credentials. Many teams use type: "smb" with smb_username, or rsync with Git for Windows' tools.
  • Coexistence. Hyper-V and VirtualBox have historically fought over hardware virtualization; recent VirtualBox versions run on top of the Windows hypervisor but at reduced speed. If you use WSL 2, stay with Hyper-V.

libvirt and KVM on Linux

KVM gives near-native performance. Vagrant reaches it through the vagrant-libvirt plugin and the libvirt daemon.

TEXT
$ sudo apt install qemu-kvm libvirt-daemon-system libvirt-dev ruby-dev build-essential
$ sudo usermod -aG libvirt $USER        # log out and in again
$ vagrant plugin install vagrant-libvirt
$ vagrant box add generic/ubuntu2204 --provider=libvirt
$ vagrant up --provider=libvirt
Ruby
Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu2204"

  config.vm.provider "libvirt" do |lv|
    lv.memory = 2048
    lv.cpus = 2
    lv.cpu_mode = "host-passthrough"   # expose the host CPU features
    lv.storage_pool_name = "default"
    lv.nested = true
  end

  config.vm.network "private_network", ip: "192.168.121.50"
end

Differences to know:

  • The default synced-folder type is NFS (needs nfs-kernel-server on the host) or rsync; VirtualBox shared folders do not exist here.
  • The management network used by Vagrant is created by libvirt (often 192.168.121.0/24); private networks you declare become additional libvirt networks.
  • Disks are qcow2 images in a storage pool, by default /var/lib/libvirt/images. Free space there matters.
  • You can inspect machines with virsh list --all alongside vagrant status.

VMware and Parallels

VMware Workstation, Fusion and Parallels Desktop are commercial products. The VMware integration comes from the vagrant-vmware-desktop plugin plus a small utility from the vendor; Parallels uses vagrant-parallels.

Ruby
Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-22.04"          # pick a box built for your CPU

  config.vm.provider "vmware_desktop" do |v|
    v.vmx["memsize"]  = "2048"
    v.vmx["numvcpus"] = "2"
    v.gui = false
  end

  config.vm.provider "parallels" do |prl|
    prl.memory = 2048
    prl.cpus   = 2
    prl.update_guest_tools = true
  end
end

VMware uses a vmx hash for settings that Vagrant has no first-class option for, which is the counterpart of VirtualBox's customize. Both products offer better graphics and disk performance than VirtualBox, and both are the realistic option on Apple silicon Macs, provided you pick arm64 boxes.

Comparing the settings

The names differ, but the idea is the same. Keep a small translation table in your head:

Idea VirtualBox Hyper-V libvirt VMware
Memory (MB) vb.memory hv.memory lv.memory v.vmx["memsize"]
CPUs vb.cpus hv.cpus lv.cpus v.vmx["numvcpus"]
Low-level escape hatch vb.customize none lv.<option> v.vmx[...]
Fast clone vb.linked_clone hv.linked_clone lv.cpu_mode, backing store v.linked_clone

A stand-in: one settings table, many providers

A tidy Vagrantfile defines resources once and applies them to each provider. This Ruby stand-in builds the per-provider settings from a shared spec, the same technique you would use inside the provider blocks. It is plain Ruby, not Vagrant.

Ruby Translate one spec for each provider

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with gets), it gets the next line from this box.

In a real file you write the provider blocks yourself, but reading values from one MEMORY and CPUS constant at the top removes duplication.

Which one should you pick?

  • Windows with WSL 2 or Docker Desktop: Hyper-V.
  • Windows without those: VirtualBox is easiest, Hyper-V is faster.
  • Linux: libvirt for speed, VirtualBox if you want the same setup as teammates.
  • Apple silicon: Parallels or VMware Fusion, or Docker provider for containers.
  • Mixed team: use generic/* or other multi-provider boxes and keep a block for each provider so everyone can use their native engine.

Common mistakes

  • Not running as administrator on Windows, which fails before any VM appears.
  • Forgetting the libvirt group membership, which gives permission-denied on the libvirt socket.
  • Using an x86 box on an ARM host. The machine boots slowly under emulation or not at all.
  • Assuming private_network IPs work identically. Always check the guest address on Hyper-V.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which provider is bundled with Vagrant and needs an administrator terminal on Windows?

    Hyper-V support ships with Vagrant, and most commands need administrator rights.
  2. 2. How do you add libvirt support?

    libvirt is a plugin and also needs the system libvirt daemon and KVM.
  3. 3. What is the VMware counterpart of VirtualBox's customize?

    Settings Vagrant does not model directly go into v.vmx[...] for VMware.
  4. 4. Which choice is best for a mixed team using Windows, Linux and Mac?

    Multi-provider boxes with provider blocks let each developer use their native hypervisor.

Summary

  • Hyper-V is built in for Windows Pro but needs administrator rights and behaves differently for networking and folders.
  • libvirt/KVM offers near-native speed on Linux through the vagrant-libvirt plugin.
  • VMware and Parallels are commercial and are the practical choice on Apple silicon.
  • Keep one resource spec and translate it into each provider block; use multi-provider boxes for mixed teams.

Next: The Docker provider