Install Centos Xen Server
Jump to Install the Xen4CentOS Stack - Xen needs a kernel built with 'domain 0' support to operate. Once that is done, we can now install xen itself.
Support - Xen Installation Guide
RedHat Enterprise Linux 6
RedHat Enterprise Linux 7
CentOS 6
CentOS 7
Scientific Linux 6
Scientific Linux 7
Support for these packages can be found in the support section of this site.
All packages are signed with the GPG Key 5838f88d. This key is part of the kernel-xen-release package. These instructions work for both RHEL6 and RHEL7.
Step 1
Download and install your base OS. I personally use Scientific Linux 7. After downloading and burning the DVD, perform a minimal install adding packages you require.
Step 2
Install the bridge-utils package.
# yum install bridge-utils
Step 3
Enable my Xen Repo for x86_64
For SL6, CentOS 6 and RHEL 6:# yum install http://au1.mirror.crc.id.au/repo/kernel-xen-release-el6-latest.noarch.rpm
For SL7, CentOS 7 and RHEL 7: # yum install http://au1.mirror.crc.id.au/repo/kernel-xen-release-el7-latest.noarch.rpm
Step 4
Choose your Xen version:
Xen 4.5
# yum install xen45 # ls -l /boot/xen.gz lrwxrwxrwx 1 root root 12 Sep 10 02:54 /boot/xen.gz -> xen-4.5.0.gz
Xen 4.6
# yum install xen46 # ls -l /boot/xen.gz lrwxrwxrwx 1 root root 12 Sep 10 02:54 /boot/xen.gz -> xen-4.6.0.gz
Xen 4.7
# yum install xen47 # ls -l /boot/xen.gz lrwxrwxrwx 1 root root 12 Sep 10 02:54 /boot/xen.gz -> xen-4.7.0.gz
Xen 4.9
# yum install xen49 # ls -l /boot/xen.gz lrwxrwxrwx 1 root root 12 Sep 10 02:54 /boot/xen.gz -> xen-4.9.0.gz
Step 5
Install the kernel-xen package. NOTE: It is important to do this AFTER installing Xen and in a separate yum command. If you combine the two, the kernel-xen package may be installed before the xen package. This will result in the required grub.conf entries not being set up.
# yum install kernel-xen
Step 6
Disable SELinux. While selinux is a great idea, it really screws with Xen. If there is anyone out there who wants to wade through what should be set for selinux to be enabled and still have Xen working, please email me! In the mean time, disable it by editing the following file /etc/sysconfig/selinux.
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
Step 7
Reboot into your new Xen kernel and test:
# xm info host : xenhost.lan.crc.id.au release : 3.8.3-1.el6xen.x86_64 version : #1 SMP Sat Mar 16 15:16:57 EST 2013 machine : x86_64 nr_cpus : 4 nr_nodes : 1 cores_per_socket : 4 threads_per_core : 1 cpu_mhz : 3303 hw_caps : bfebfbff:28100800:00000000:00003f40:179ae3bf:00000000:00000001:00000000 virt_caps : hvm total_memory : 8116 free_memory : 322 free_cpus : 0 xen_major : 4 xen_minor : 2 xen_extra : .1 xen_caps : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64 xen_scheduler : credit xen_pagesize : 4096 platform_params : virt_start=0xffff800000000000 xen_changeset : unavailable xen_commandline : dom0_mem=2048M cpufreq=xen dom0_max_vcpus=2 dom0_vcpus_pin cc_compiler : gcc (GCC) 4.4.6 20120305 (Red Hat 4.4.6-4) cc_compile_by : mockbuild cc_compile_domain : crc.id.au cc_compile_date : Sat Feb 16 19:16:38 EST 2013 xend_config_format : 4
On this page
- Installing Xen On CentOS 5.0 (i386)
Installing Xen On CentOS 5.0 (i386)
Version 1.0
Author: Falko Timme
This tutorial provides step-by-step instructions on how to install Xen (version 3.0.3) on a CentOS 5.0 system (i386).
Xen lets you create guest operating systems (*nix operating systems like Linux and FreeBSD), so called 'virtual machines' or domUs, under a host operating system (dom0). Using Xen you can separate your applications into different virtual machines that are totally independent from each other (e.g. a virtual machine for a mail server, a virtual machine for a high-traffic web site, another virtual machine that serves your customers' web sites, a virtual machine for DNS, etc.), but still use the same hardware. This saves money, and what is even more important, it's more secure. If the virtual machine of your DNS server gets hacked, it has no effect on your other virtual machines. Plus, you can move virtual machines from one Xen server to the next one.
I will use CentOS 5.0 (i386) for both the host OS (dom0) and the guest OS (domU).
This howto is meant as a practical guide; it does not cover the theoretical backgrounds. They are treated in a lot of other documents in the web.
This document comes without warranty of any kind! I want to say that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!
1 Preliminary Note
I use the following partitions on my CentOS 5.0 host system (dom0):
- /boot 150 MB (ext3)
- swap 1GB
- / 3GB (ext3)
- /vm the rest (ext3)
I will create the virtual machines in the /vm directory; of course, you can use any other directory that has enough space left, and you don't have to create a partition of its own for it. If you use another directory, replace /vm with your own directory in this tutorial.
If you want to save your virtual machines in /vm, too, but haven't created a partition for it of if the directory /vm doesn't exist on your system, you can create it like this:
(Please note: You don't need a /boot partition, but then you have to keep in mind that the Grub stanzas I describe in this howto are slightly different. For example, when I write that I add
to /boot/grub/menu.lst then you should probably use
in that file instead..)
2 Installing Xen
To install Xen, we simply run
This installs Xen and a Xen kernel on our CentOS system. Afterwards, we can find our new Xen kernel (vmlinuz-2.6.18-8.1.4.el5xen) and its ramdisk (initrd-2.6.18-8.1.4.el5xen.img) in the /boot directory:
[[email protected] ~]# ls -l /boot/
total 16327
-rw-r--r-- 1 root root 62154 Apr 9 16:30 config-2.6.18-8.1.1.el5
-rw-r--r-- 1 root root 61057 May 17 12:12 config-2.6.18-8.1.4.el5xen
-rw-r--r-- 1 root root 62150 Mar 16 01:19 config-2.6.18-8.el5
drwxr-xr-x 2 root root 1024 Jun 8 00:14 grub
-rw------- 1 root root 2318110 Apr 13 17:10 initrd-2.6.18-8.1.1.el5.img
-rw------- 1 root root 2320081 Jun 8 00:14 initrd-2.6.18-8.1.4.el5xen.img
-rw------- 1 root root 2318126 Apr 13 16:18 initrd-2.6.18-8.el5.img
drwx------ 2 root root 12288 Apr 13 16:05 lost+found
-rw-r--r-- 1 root root 80032 Apr 1 16:49 message
-rw-r--r-- 1 root root 83542 Apr 9 16:31 symvers-2.6.18-8.1.1.el5.gz
-rw-r--r-- 1 root root 84906 May 17 12:13 symvers-2.6.18-8.1.4.el5xen.gz
-rw-r--r-- 1 root root 83542 Mar 16 01:20 symvers-2.6.18-8.el5.gz
-rw-r--r-- 1 root root 884787 Apr 9 16:30 System.map-2.6.18-8.1.1.el5
-rw-r--r-- 1 root root 868062 May 17 12:12 System.map-2.6.18-8.1.4.el5xen
-rw-r--r-- 1 root root 884787 Mar 16 01:19 System.map-2.6.18-8.el5
-rw-r--r-- 1 root root 1765460 Apr 9 16:30 vmlinuz-2.6.18-8.1.1.el5
-rw-r--r-- 1 root root 2075341 May 17 12:12 vmlinuz-2.6.18-8.1.4.el5xen
-rw-r--r-- 1 root root 1765428 Mar 16 01:19 vmlinuz-2.6.18-8.el5
-rw-r--r-- 1 root root 274228 May 17 09:13 xen.gz-2.6.18-8.1.4.el5
-rwxr-xr-x 1 root root 608568 May 17 12:28 xen-syms-2.6.18-8.1.4.el5
[[email protected] ~]#
Before we can boot the system with the Xen kernel, we must tell the bootloader GRUB about it. We open /boot/grub/menu.lst:
and add the following stanza above all other kernel stanzas:
Then change the value of default to 0:
The complete /boot/grub/menu.lst should look something like this:
Afterwards, we reboot the system:
The system should now automatically boot the new Xen kernel. After the system has booted, we can check that by running
[[email protected] ~]# uname -r
2.6.18-8.1.4.el5xen
[[email protected] ~]#
So it's really using the new Xen kernel!
We can now run
to check if Xen has started. It should list Domain-0 (dom0):
[[email protected] ~]# xm list
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 350 1 r----- 94.4
[[email protected] ~]#
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
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 (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.0/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.0 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.0 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:
Run
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
The output should look like this:
[[email protected] xen]# xm list
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 259 1 r----- 1906.6
vm01 3 255 1 ------ 137.9
[[email protected] xen]#
To shut down vm01, do this: Autotune 7 for mac torrent.
To start vm01 again, run
If you want vm01 to start automatically at the next boot of the system, then do this:
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
- Xen: http://www.xensource.com/xen
- CentOS: http://www.centos.org