Preferences

In terms of speed, how is virt-builder compare to say Terraform?

Terraform is dog slow sometimes due to cloud provisioning. Would be nice to just be able to build the VM locally then push the AMI/VHD into AWS or Azure.


virt-builder can usually build out a disk image in 15-60 seconds if the template has already been downloaded and you're running on baremetal. Might be 120 seconds if you have to use nested KVM or TCG.

  $ virt-builder fedora-33
  [   1.5] Downloading: http://builder.libguestfs.org/fedora-33.xz
  [   2.3] Planning how to build this image
  [   2.3] Uncompressing
  [   8.6] Opening the new disk
  [  13.8] Setting a random seed
  [  13.8] Setting passwords
  virt-builder: Setting random password of root to mZbPJw9d1ZHgowBk
  [  14.8] Finishing off
                   Output file: fedora-33.img
                   Output size: 6.0G
                 Output format: raw
            Total usable space: 6.0G
                    Free space: 4.7G (79%)
By the way, interesting virt-builder factoid: It uses a STRIPS-based planner to optimize the order of steps when building the image, so it doesn't waste time doing multiple copies. https://en.wikipedia.org/wiki/Stanford_Research_Institute_Pr... https://github.com/rwmjones/guestfs-tools/blob/0cffcbb7848af... https://github.com/libguestfs/libguestfs-common/blob/74bc5c5... https://github.com/libguestfs/libguestfs-common/blob/74bc5c5...
kashyapc
I don't know how Terraform works, but `virt-builder` will cache the xz-compressed template images locally on your first pull. So for example, if you build a Fedora image:

    $ virt-builder fedora-32 --size 10G --format qcow2
Then the (xz-compressed) template Fedora 32 image will be cached under ~/.cache/virt-builder. So your subsequent Fedora 32 image provisioning will be much faster.

You might want to give it a whirl and see if it satisfies your needs; `virt-builder` should be available on most major Linux distributions.

This item has no comments currently.