Installing KVM Guests With virt-install On Ubuntu 10.10 Server

Version 1.0
Author: Falko Timme
Follow me on Twitter

Unlike virt-manager, virt-install is a command line tool 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 10.10 KVM server.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

I'm assuming that KVM is already installed (e.g. as shown here: Virtualization With KVM On Ubuntu 10.10). My KVM host has the IP address 192.168.0.100.

I will show how to install a CentOS 5.5 guest in this tutorial.

We also need an Ubuntu 10.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 10.10 KVM server or on a remote system.

 

2 Installing virt-install

Open a terminal and install virt-install:

sudo apt-get install virtinst

 

3 Installing virt-viewer Or virt-manager On Your Ubuntu 10.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 10.10 desktop (it doesn't matter if it is a remote desktop of if the desktop is installed on the Ubuntu 10.10 KVM server!).

If you want to use virt-viewer, run

sudo apt-get install virt-viewer

If you want to use virt-manager, run

sudo apt-get install virt-manager

 

4 Creating A CentOS 5.5 Guest

Take a look at

man virt-install

to learn how to use it.

To create a CentOS 5.5 guest (in bridging mode) with the name vm10, 512MB of RAM, two virtual CPUs, and the disk image ~/vm10.qcow2 (with a size of 12GB), insert the CentOS DVD into the CD drive and run

sudo virt-install --connect qemu:///system -n vm10 -r 512 --vcpus=2 -f ~/vm10.qcow2 -s 12 -c /dev/cdrom --vnc --noautoconsole --os-type linux --accelerate --network=bridge:br0 --hvm

Of course, you can also create an ISO image of the CentOS DVD...

sudo dd if=/dev/cdrom of=~/CentOS-5.5-x86_64-bin-DVD.iso

... and use the ISO image in the virt-install command:

sudo virt-install --connect qemu:///system -n vm10 -r 512 --vcpus=2 -f ~/vm10.qcow2 -s 12 -c ~/CentOS-5.5-x86_64-bin-DVD.iso --vnc --noautoconsole --os-type linux --accelerate --network=bridge:br0 --hvm

 

5 Connecting To The Guest

The KVM guest will now boot from the CentOS 5.5 DVD and start the graphical CentOS installer - that's why we need to connect to the graphical console of the guest. You can either do this with virt-manager (see KVM Guest Management With Virt-Manager On Ubuntu 8.10) or with virt-viewer. I will show how to do this with virt-viewer.

If virt-viewer is installed on the KVM server, you can run

sudo virt-viewer vm10

If virt-viewer is installed on a remote Ubuntu desktop, run

sudo virt-viewer --connect qemu+ssh://[email protected]/system vm10

(Replace 192.168.0.100 with the IP address or hostname of the KVM host. Please note that the root account must be enabled on the KVM host, and that root logins must be allowed on the KVM host. To enable the root login on an Ubuntu system, run

sudo passwd root

To check if root logins are allowed check the directive PermitRootLogin in /etc/ssh/sshd_config - you might have to restart the SSH daemon afterwards. )

You should now be connected to the graphical console of the guest and see the CentOS installer:

Now install CentOS as you would normally do on a physical system. Please note that at the end of the installation, the CentOS system needs a reboot. The guest will then stop, so you need to start it again, either with virt-manager or like this on the KVM host's command line:

sudo virsh --connect qemu:///system
start vm10
quit

Afterwards, you can connect to the guest again with virt-viewer or virt-manager and complete the installation.

 

6 Cloning Guests

The python-virtinst package comes with a second tool, virt-clone, that lets you clone guests. To clone vm10 and name the clone vm11 with the disk image ~/vm11.qcow2, you simply run

sudo virt-clone --connect qemu:///system -o vm10 -n vm11 -f ~/vm11.qcow2

Afterwards, you can start vm11 with virt-manager or like this...

sudo virsh --connect qemu:///system
start vm11
quit

... and connect to it using virt-manager or virt-viewer.

 

Share this page:

0 Comment(s)