The newest upstream virt-builder can now build simple VMs in around 30 seconds (this is on a machine with a hard drive, it’s faster if you have SSDs):
$ virt-builder ubuntu-12.04 [ 0.0] Downloading: file:///home/rjones/d/libguestfs/builder/website/ubuntu-12.04.xz [ 1.0] Creating disk image: ubuntu-12.04.img [ 1.0] Uncompressing: file:///home/rjones/d/libguestfs/builder/website/ubuntu-12.04.xz [ 9.0] Opening the new disk [ 33.0] Setting a random seed [ 33.0] Random root password: z6T5zQiqIIy0yZfA [did you mean to use --root-password?] [ 33.0] Finishing off Output: ubuntu-12.04.img Total usable space: 2.9G Free space: 2.1G (73%)
Even installing packages in the VM, it’s still taking under 1 minute:
$ virt-builder ubuntu-12.04 --install nmap [ 0.0] Downloading: file:///home/rjones/d/libguestfs/builder/website/ubuntu-12.04.xz [ 1.0] Creating disk image: ubuntu-12.04.img [ 1.0] Uncompressing: file:///home/rjones/d/libguestfs/builder/website/ubuntu-12.04.xz [ 10.0] Opening the new disk [ 34.0] Setting a random seed [ 34.0] Random root password: Mt3kxbEsBqumG6bR [did you mean to use --root-password?] [ 34.0] Installing packages: nmap [ 53.0] Finishing off Output: ubuntu-12.04.img Total usable space: 2.9G Free space: 2.0G (70%)
The major changes are: It will use pxzcat (parallel xzcat) if available, and it will bypass the virt-resize step if you don’t specify the --size
option (or if you make sure the templates are the right size to start with).
Update:
On a machine with an Intel SSD and parallel xzcat installed:
$ virt-builder ubuntu-12.04 [ 0.0] Downloading: file:///home/rjones/d/libguestfs/builder/website/ubuntu-12.04.xz [ 1.0] Creating disk image: ubuntu-12.04.img [ 1.0] Uncompressing: file:///home/rjones/d/libguestfs/builder/website/ubuntu-12.04.xz [ 12.0] Opening the new disk [ 16.0] Setting a random seed [ 16.0] Random root password: JdIsqD5QB64yImYL [did you mean to use --root-password?] [ 16.0] Finishing off Output: ubuntu-12.04.img Total usable space: 2.9G Free space: 2.1G (73%)