INTRODUCTION
We will create our image-based virtual machines in the directory /var/lib/libvirt/images/ which was created automatically when we installed libvirt.
INSTALLATION
CentOS has a nice tool called virt-install with which we can create virtual machines for Xen. To start it, we simply run
#virt-install -–prompt -–network bridge=br0 -–virt-type=xen
(We must specify our network bridge with –network bridge=br0 so that the virtual machine uses our network bridge which we created in previous blog xen installation).
The tools asks a few questions before it creates a virtual machine. I want to call my first virtual machine vm01, with 1024MB RAM and a disk size of 10GB. I want to store it in the file /var/lib/libvirt/images/sathishvm.img:
Would you like a fully virtualized guest (yes or no)? This will allow you to run unmodified operating systems.
<– no
What is the name of your virtual machine?
<– sathishvm
How much RAM should be allocated (in megabytes)?
<– 1024
What would you like to use as the disk (file path)?
<– /var/lib/libvirt/images/sathishvm.img
How large would you like the disk (/var/lib/libvirt/images/vm01.img) to be (in gigabytes)?
<– 10
What is the install URL?
<– http://ftp.tu-chemnitz.de/pub/linux/centos/6.3/os/x86_64
In this chapter I want to create a paravirtualized guest, not a fully (hardware) virtualized guest, that’s why I answer the first question with no.
As install URL, you should specify a mirror close to you where the installer can download all files needed for the installation of CentOS 6.3 in our virtual machine.
After we have answered all questions, virt-install starts the normal CentOS 6.3 installer (in text mode) in our sathishvm virtual machine.
After the installation, we stay at the sathishvm console.If you are at the console, or CTRL+5 if you’re using PuTTY. You will then be back at the dom0console.
Run
#virsh console sathishvm
to log in on that virtual machine again (type CTRL+] if you are at the console, or CTRL+5 if you’re using PuTTY to go back to dom0), or use an SSH client to connect to it.
To get a list of running virtual machines, type
To shut down sathish, do this:
#virsh shutdown sathishvm
To start sathishvm again, run
#virsh start sathishvm
Here are the most important Xen commands:
virsh start <name> – Start a virtual machine.
virsh shutdown <name> – Stop a virtual machine.
virsh destroy <name> – Stop a virtual machine immediately without shutting it down. It’s as if you switch off the power button.
virsh list – List all running systems.
virsh console <name> – Log in on a virtual machine.
virsh help – List of all commands.
















