virt-builder and virt-install together make it easy to create libvirt guests in just a few minutes.
Before you start, read the installation notes for the OS you’re about to install. They may contain essential tips for a successful installation:
$ virt-builder --notes ubuntu-13.10 [...]
Note I’m running this as root, but that’s only necessary because I want to write the guest to a logical volume. Normally you don’t (and shouldn’t) run virt-builder as root.
# lvcreate -L 50G -n builder-ubuntu1310 /dev/vg_data # virt-builder ubuntu-13.10 \ --output /dev/vg_data/builder-ubuntu1310 \ --hostname builder-ubuntu1310 \ --install build-essential,debhelper [ 0.0] Downloading: http://libguestfs.org/download/builder/ubuntu-13.10.xz [ 1.0] Uncompressing: http://libguestfs.org/download/builder/ubuntu-13.10.xz [ 23.0] Running virt-resize to expand the disk [ 99.0] Opening the new disk [ 103.0] Setting a random seed [ 103.0] Setting the hostname: builder-ubuntu1310 [ 103.0] Random root password: mOQ8YdwKuxkMlpOU [did you mean to use --root-password?] [ 103.0] Installing packages: build-essential debhelper [ 423.0] Finishing off Output: /dev/vg_data/builder-ubuntu1310 Total usable space: 48.2G Free space: 47.1G (97%) # virt-install --import \ --name builder-ubuntu1310 --ram 4096 \ --disk path=/dev/vg_data/builder-ubuntu1310,format=raw
(Yes, I forgot to use the
--root-password option …)