Virtualization With KVM On A CentOS 5.2 Server - Page 2

4 Creating A Debian Lenny Guest (Image-Based)

CentOs 5.2 KVM Host:

Now let's go back to our CentOS 5.2 KVM host.

Take a look at

man virt-install

to learn how to use virt-install.

To create a Debian Lenny 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 Debian Lenny Netinstall CD into the CD drive and run

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

(The virt-install man page shows the values that are valid for --os-type and --os-variant. The virt-install version that comes with CentOS 5.2 doesn't know Debian Lenny, so we use generic26 for --os-variant.)

Of course, you can also create an ISO image of the Debian Lenny Netinstall CD...

dd if=/dev/cdrom of=~/debian-500-amd64-netinst.iso

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

virt-install --connect qemu:///system -n vm10 -r 512 --vcpus=2 -f ~/vm10.qcow2 -s 12 -c ~/debian-500-amd64-netinst.iso --vnc --noautoconsole --os-type linux --os-variant generic26 --accelerate --network=bridge:br0 --hvm

The output is as follows:

[[email protected] ~]# virt-install --connect qemu:///system -n vm10 -r 512 --vcpus=2 -f ~/vm10.qcow2 -s 12 -c ~/debian-500-amd64-netinst.iso --vnc --noautoconsole --os-type linux --os-variant generic26 --accelerate --network=bridge:br0 --hvm

Starting install...
Creating storage file...  100% |=========================|  12 GB    00:00
Creating domain...                                                 0 B 00:00
Domain installation still in progress.  You can reconnect to
the console to complete the installation process.
[[email protected] ~]#


5 Connecting To The Guest

Ubuntu 8.10 Desktop:

The KVM guest will now boot from the Debian Lenny Netinstall CD and start the Debian installer - that's why we need to connect to the graphical console of the guest. You can do this with virt-manager on the Ubuntu 8.10 desktop (see KVM Guest Management With Virt-Manager On Ubuntu 8.10).


sudo virt-manager

on the Ubuntu desktop to start virt-manager.

(If you are on a Fedora 10 desktop, run:




In virt-manager, connect to the KVM host:

Type in the root password of the KVM host:

You should see vm10 as running. Mark that guest and click on the Open button to open the graphical console of the guest:

Type in the root password of the KVM host again:

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

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

CentOS 5.2 KVM Host:

virsh --connect qemu:///system

start vm10


Afterwards, you can connect to the guest again with virt-manager and configure the guest. If you install OpenSSH (package openssh-server) in the guest, you can connect to it with an SSH client (such as PuTTY).

Falko Timme

About Falko Timme

Falko Timme is an experienced Linux administrator and founder of Timme Hosting, a leading nginx business hosting company in Germany. He is one of the most active authors on HowtoForge since 2005 and one of the core developers of ISPConfig since 2000. He has also contributed to the O'Reilly book "Linux System Administration".

Share this page:

Suggested articles

0 Comment(s)

Add comment


By: Falko Timme