On Ditching Vagrant - benjamintoll.com
13 min read
On Ditching Vagrant
June 29, 2026
Goodbye, old friend. We’ve been traveling together since 2010, and you’ve faithfully served all my virtual machine needs well, first with VirtualBox and then later with libvirt and KVM. But, as they1 say, all good things must pass.
What happened? What has changed?
Introduction
KVM and libvirt and virsh
ruh-roh
Preseeding
Network Connectivity
Mounting
SSH Agent Forwarding
Summary
References
Introduction
So, what are we doing here? Why are we parting ways? Honestly, I have found that Vagrant is just too much software for little old me. As I continue my learning journey throughout this wee life and become exposed to more and more things, I question and re-evaluate some of my earlier choices when I didn’t know as much as I do now. I’ve always revisited past project and decisions, and this has served me well. In this case, I saw that I was making my workflow too complex.
When I first started using Vagrant in 2010, I was content just to have it manage the lifecycle of my VMs. Vagrant boxes were cool and saved me time, and then later on as I started using Ansible, I started provisioning my machines with Vagrant’s builtin Ansible support.
But as I continued learning more and more about Linux, I started wondering why I just didn’t use KVM instead of Vagrant. After all, it’s been merged into the Linux kernel since version 2.6.20, so I already have the tools I need to create and manage virtual machines. Why have another software layer, another abstraction, to create something that Linux can do natively?
I started feeling like a weenie. I began feeling like a smelly little turd. Worst of all, I realized that I was being lazy. So, I switched from the VirtualBox provider to the libvirt provider as a half-measure several years ago and moved on with my life. After all, I had much more important things to do, such as working as very hard as I very could for my then-employer and their customers, since they told me that that was the important thing, the most important thing, so important that I should get up at 3am on consecutive nights to fix hasty infrastructure that we weren’t given time to fix during the work week because Agile and because Scrum master and because it didn’t provide value to the customer.
Anyway, after a couple of years of this shameful behavior, I finally set aside time to dig into KVM and libvirt and do it right. That’s right, children, I uninstalled Vagrant2 and my wife started to love me again.
So, what did I do? Come, join me around the fire, and let’s all learn together.
KVM and libvirt and virsh
KVM allows the Linux kernel to function as a hypervisor, creating and running virtual machines (VMs), via a kernel virtualization module. Through virtualization, hardware is emulated in software, so creating a VM is like having an entire operating system within your host operating system. Isn’t that cool? You bet your booties!
The kernel module is probably enabled. To check:
$ lsmod | ag kvm<br>kvm_intel 380928 0<br>kvm 1146880 1 kvm_intel<br>irqbypass 16384 1 kvm
Or:
$ ls /dev/kvm<br>/dev/kvm
libvirt, on the other hand, is a library and network daemon (pronounced as demon, not “daymon”) that manages KVM other virtualization platforms, like Xen, LXC and QEMU. It allows you to create, start, stop, pause and delete VMs, among other things like storage and network management. What’s really nice about libvirt is that it gives a unified and common library when interacting with all the different platforms that it supports, so there is no need to use anything else or learn different commands and operations for different hypervisors. In other words, if you switch out your virtualization backend, you can continue to use libvirt using the same commands.
To install it:
$ sudo apt-get install libvirt-daemon-system
virsh is a command-line frontend to libvirt (libvirt also supports other frontends, like virt-manager, but that’s a GUI, and everybody knows that no one uses GUIs when there’s a CLI tool available). It gives you a nice abstraction layer to interact with the libvirt daemon, which, in turn, interacts with KVM.
To install it:
$ sudo apt-get install libvirt-clients virtinst
This will also install virt-install
Here are some helpful virsh commands to get information about a virtual machine (i.e., domain):
domblkinfo
domblkstat
domid
domiflist
domifstat
dominfo
dommemstat
domname
domstate
domuuid
And, to get information about the host and about a node:
capabilities
hostname
nodeinfo
And, useful management commands:
connect
destroy
dumpxml
edit
list
reboot
shutdown
start
undefine
There really are too many to list here. See the virsh docs.
Again, the conceptual model is user -> virsh -> libvirt -> KVM.
There is a lot more to understand about each of these topics, but this will get you...