Previously (some years back) I have used vmbuilder, but this now seems to be unmaintained and cannot be used with newer ubuntu versions.

I have also tried vagrant with vagrant-libvirt plugin, apart from this method requires a huge amount of packages to be installed it didn't work in the end after all because there is no ubuntu cloud images for the libvirt provider.

I have also looked into standard virt-installer providing the standard ISO image as CD-ROM, but that is not non-interactive. Apart from that I also ran into a ubiquity bug during the interactive installation.

So what is the best way to non-interactively provision ubuntu virtual machines using libvirt? Or what is the replacement of vmbuilder?


I think you are looking for virt-builder.

Virt-builder starts with cleanly installed OS templates for a variety of distributions and allows you to customize them by setting a root password, copying in files, and more.

Virt-builder is in the libguestfs-tools package.

sudo apt install libguestfs-tools

These basic commands should get you started; you can find more advanced stuff in the man page.

List the available VM templates:

virt-builder --list

Create a fresh Ubuntu 18.04 LTS image:

virt-builder ubuntu-18.04

By default, virt-builder creates no user accounts, and enables the root account with a random password, which is printed on your terminal when the VM image is created. As mentioned before, you can change this with various command options.

(Note that with respect to Ubuntu, virt-builder only supports LTS releases of Ubuntu.)

  • This looks like the tool I was looking for. However I run into issues using virt-builder. I have reported it on bugs.launchpad.net/ubuntu/+source/libguestfs/+bug/1813662 – Jarl Jan 28 at 21:05
  • 1
    Well, at least there's a workaround. – Michael Hampton Jan 28 at 22:32
  • virt-builder only creates the disk I am still missing the xml-file, i.e. the domain definition in libvirt. – Jarl Jan 30 at 14:28
  • @Jarl You can easily create the VM to your own desires using virt-install and using the --import option to tell it to use the existing disk, rather than trying to run an OS installer. – Michael Hampton Jan 30 at 15:01
  • Could you add the final steps needed to provision a ubuntu server so that it will show up on the output from virsh list? – Jarl Feb 4 at 13:12

I'd recommend taking a look at either uvtool which in my experience works much better than virt-builder.

But given it is no more 2016 I'd actually recommend even more taking a look at the modern and even cross platform solution of multipass. By default that would spawn qemu directly but you can make it use the libvirt backend instead with

snap set multipass driver=LIBVIRT

Both tools will give you a CLI interface to spawn guests based on Ubuntu cloud images.

  • Thanks for the pointers to both tools, very nice. If you by "spawning" mean "run" then I am not so much interested in spawning guests, I will use virsh for that, I am interested in building/creating the guests, that is, creating a virtual disk image and an XML file that defines a domain that is seen in the output from virsh list. – Jarl Jan 31 at 5:42
  • Yeah, that will all work. After the initial creation you can use plain libvirt/virsh as you like. – Christian Ehrhardt Feb 1 at 9:46

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.