Installing Xen On CentOS 5.2 (i386) - Page 2

3 Creating A Virtual Machine

CentOS comes with a nice tool called virt-install with which we can create virtual machines for Xen. To start it, we simply run

virt-install

The tools asks a few questions before it creates a virtual machine. I want to call my first virtual machine vm01, with 256MB RAM and a disk size of 4GB. I want to store it in the file /vm/vm01.img:

What is the name of your virtual machine? <-- vm01
 How much RAM should be allocated (in megabytes)? <-- 256
 What would you like to use as the disk (file path)? <-- /vm/vm01.img
 How large would you like the disk (/vm/vm01.img) to be (in gigabytes)? <-- 4
 Would you like to enable graphics support? (yes or no) <-- no
 What is the install location? <-- http://wftp.tu-chemnitz.de/pub/linux/centos/5.2/os/i386

The question about the graphics support refers to the installer, not the virtual machine itself! It is possible to start a graphical installer, but you'd have to connect to it via VNC. It's easier to use the text installer - it offers the same options, so I choose the text installer.

As install location, you should specify a mirror close to you where the installer can download all files needed for the installation of CentOS 5.2 in our virtual machine. You can find a list of CentOS mirrors here: http://www.centos.org/modules/tinycontent/index.php?id=13

After we have answered all questions, virt-install starts the normal CentOS 5.2 installer (in text mode) in our vm01 virtual machine. You already know the CentOS installer, so it should be no problem for you to finish the CentOS installation in vm01.

After the installation, we stay at the vm01 console. To leave it, type CTRL+] if you are at the console, or CTRL+5 if you're using PuTTY. You will then be back at the dom0 console.

virt-install has created the vm01 configuration file /etc/xen/vm01 for us (in dom0). It should look like this:

cat /etc/xen/vm01

name = "vm01"
uuid = "6c835c75-41da-b13f-ec1b-946c4079ec17"
maxmem = 256
memory = 256
vcpus = 1
bootloader = "/usr/bin/pygrub"
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
vfb = [  ]
disk = [ "tap:aio:/vm/vm01.img,xvda,w" ]
vif = [ "mac=00:16:3e:7a:27:02,bridge=xenbr0" ]

Run

xm console vm01

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

xm list

The output should look like this:

[root@server1 ~]# xm list
Name                                      ID Mem(MiB) VCPUs State   Time(s)
Domain-0                                   0      771     1 r-----    283.5
vm01                                       1      255     1 -b----    237.6
[root@server1 ~]#

To shut down vm01, do this:

xm shutdown vm01

To start vm01 again, run

xm create /etc/xen/vm01

If you want vm01 to start automatically at the next boot of the system, then do this:

ln -s /etc/xen/vm01 /etc/xen/auto

Here are the most important Xen commands:

xm create -c /path/to/config - Start a virtual machine.
xm shutdown <name> - Stop a virtual machine.
xm destroy <name> - Stop a virtual machine immediately without shutting it down. It's as if you switch off the power button.
xm list - List all running systems.
xm console <name> - Log in on a virtual machine.
xm help - List of all commands.

 

4 Links

Share this page:

9 Comment(s)

Add comment

Comments

From: LiRo at: 2008-11-07 08:33:17

Note:

 To get updated the xen-kernel automatically (and booted as default) change in /etc/sysconfig/kernel the variable "defaultkernel" to "kernel-xen" instead of "kernel"....this way after a kernel update your xen kernel will be booted as default...(and not again normal kernel)

From: Anonymous at: 2008-11-12 14:46:00

If you don't understand SELinux, don't just disable it.  Google your problem and fix it.

instead of using /vm, use /xen .

Then run this command to have the correct selinux context:

restorecon -R /xen

 

From: paalfe at: 2008-11-27 15:36:00

Xen + ConVirt = Exelent.
http://xenman.sourceforge.net

Project ConVirt is an active, open source project concieved with the goal of tackling the administrative and infrastructure management challenges that adoption of virtualization platforms presents to the traditional datacenter. The eponymous tool "ConVirt" is the project's foremost offering. 


ConVirt is an intuitive, graphical management console providing comprehensive life cycle management for Virtual Machines and virtualization infrastructures. ConVirt is built on the firm design philosophy that ease-of-use and sophistication can, and should, co-exist in a single management tool. With its central console paradigm, performance and configuration dashboard, soup-to-nuts Virtual Machine lifecycle management, integrated Virtual Appliance Catalogue, and many more great features, ConVirt is proving an invaluable tool for seasoned administrators as well as those new to virtualization. 

With ConVirt's secure, multi-node capabilities, infrastructure administrators can safely manage their entire environment from a single, centralized console. Most common administrative tasks like starting/stopping/provisioning virtual machines (Guest OS's) typically involve just a few mouse clicks with ConVirt; as do server management operations like scanning OS configurations or acquiescing individual servers for maintainance. Finally, ConVirt's enterprise grade rapid-provisioning and template management capabilities are an invaluable asset to administrators responsible for QA and Test labs everywhere. 

ConVirt is completely free. It is distributed under the GNU General Public License (GPL).

From: Anonymous at: 2008-12-03 20:32:36

Is this tutorial good to install on Centos 5 64bit?

From: Anonymous at: 2009-01-19 14:52:00

I stopped reading at:

"Make sure that SELinux is disabled or permissive:"

 How can an admin that always recommends disabling SELinux provide expert knowledge on other *NIX subjects?

From: admin at: 2009-01-19 17:26:24

Just because the developers of the OS think that something is a good idea, it doesn't mean that you must use it. It was possible to run secure servers before SELinux, you know.

From: Johan at: 2009-01-21 11:03:47

I assume the i386 version differs from the 64 bit version I installed. Virtualisation is an installation option, and Xen is automatically installed, so you can turn to the second page of this manual. The text option in virt-install fails (description of this bug can be found on the internet), but with the --vnc option the installation works as described. Use virt-viewer to connect with vnc to the machine.

From: Ken at: 2008-12-12 21:09:15

One quick comment.  This is not Xen 3.0.3 on RedHat 5.2.

xen-3.0.3-64.el5_2.3.rpm != Xen version 3.0.3

This is Xen 3.1.2 on RedHat 5.2.  RedHat is just retarded and packages this in a xen-3.0.3 RPM.

Thanks,
Ken

From: Johan at: 2009-01-23 15:59:58

For, say, European users, the use of something like keymap=”fr-be” (use the appropriate value) in the configuration file is interesting, if only to be able to read what you wrote. My first idea was that there was something wrong with virt-viewer. It isn't. Everything is controlled through the configuration file.