Installing KVM Guests With virt-install On Ubuntu 11.10 Server

Unlike virt-manager, virt-install is a command line tools that allows you to create KVM guests on a headless server. You may ask yourself: "But I can use vmbuilder to do this, why do I need virt-install?" The difference between virt-install and vmbuilder is that vmbuilder is for creating Ubuntu-based guests, whereas virt-install lets you install all kinds of operating systems (e.g. Linux, Windows, Solaris, FreeBSD, OpenBSD) and distributions in a guest, just like virt-manager. This article shows how you can use it on an Ubuntu 11.10 KVM server.

We also need an Ubuntu 11.10 desktop so that we can connect to the graphical console of our KVM guests. It doesn't matter if the desktop is installed on the Ubuntu 11.10 KVM server or on a remote system (there are small differences if the desktop is installed on the KVM host compared to a remote desktop, but I will outline these differences, so read carefully).

2 Installing virt-install

Ubuntu 11.10 KVM Host:

Open a terminal and install virt-install:

sudo apt-get install virtinst

3 Installing virt-manager On Your Ubuntu 11.10 Desktop

Ubuntu 11.10 Desktop:

We need a means of connecting to the graphical console of our guests - we can use virt-viewer or virt-manager (see KVM Guest Management With Virt-Manager On Ubuntu 8.10) for this. I'm assuming that you're using an Ubuntu 11.10 desktop (it doesn't matter if it is a remote desktop of if the desktop is installed on the Ubuntu 11.10 KVM server!).

I suggest you use virt-manager instead of virt-viewer because virt-manager lets you also create and delete virtual machines and do other tasks. virt-manager can be installed as follows:

sudo apt-get install virt-manager

4 Creating A CentOS 6.0 Guest

Ubuntu 11.10 KVM Host:

Now let's go back to our Ubuntu 11.10 KVM host.

Take a look at

man virt-install

to learn how to use it.

We will create our image-based virtual machines in the directory /var/lib/libvirt/images/ which was created automatically when we installed KVM.

To create a CentOS 6.0 guest (in bridging mode) with the name vm10, 1024MB of RAM, two virtual CPUs, and the disk image /var/lib/libvirt/images/vm10.img (with a size of 12GB), insert the CentOS DVD into the CD drive and run

Of course, you can also create an ISO image of the CentOS DVD (please create it in the /var/lib/libvirt/images/ directory because later on I will show how to create virtual machines through virt-manager from your Ubuntu desktop, and virt-manager will look for ISO images in the /var/lib/libvirt/images/ directory)...