This is a demo to explain how to make custom boxes in vagrant
that use the libvirt
provider
Recording for posterity, where I will ultimately forget
The following guides were used to make this demo:
- Stackoverflow - how to create custom vagrant box from libvirt/kvm instance?
- PopOS 20.10 Guest OS support? for guest detection
- This was a specific hack needed for the image I'm building here, but may come in handy for other images
This is done on Pop!_OS 20.10
which is based on Ubuntu 20.10
This guide presumes you've already followed general procedure for setting up a box.
Lets say you're at the spot where your libvirt
VM is ready to packaging.
Follow ./boxit.sh
. The steps include:
- Copy your box over from
/var/lib/libvirt/images
tobox.img
. It must be in theqcow2
format - Create a
metadata.json
andVagrantfile
tar
the following files:
box.img
Vagrantfile
metadata.json
- That should be it. Load into vagrant with
vagrant box add --name custom custom_box.box
- Upload to https://app.vagrantup.com
This is following the older box
guide where they were just tar
archives
https://www.vagrantup.com/docs/boxes/format
You can also use:
vagrant repackage
to get a.box
files e.g.vagrant box repackage pop_os_2110 libvirt 1.1.0
vagrant cloud provider upload
to upload to vagrant cloud e.g.vagrant cloud provider upload kentbrockman/pop_os_2110 libvirt 1.1.0 package.box