Install Xen 4.6 on CentOS 6.8



I have multiple Xen hosts, and I figured that I should share the setup procedure that I use to make my Virtualization Hosts, so here it goes.

First thing to do is make sure that your CPU supports hardware virtualization, otherwise you will only be able to create paravirtualized virtual machines.

Host OS Installation:

You should download the latest minimal ISO of CentOS 6.8 and install it on your chosen host, keep in mind during installation to make a 500mb boot partition, you will want this later because usually your Xen host will have 4 different kernels available. (The Xen main kernel, as well as it’s previous verions, and the normal Linux kernel and its previous version.) Configure your networking so that you can access the internet, don’t spend too much time on this because you will be changing it all around later.

Click Here to download Centos 6.8 Minimal

Installing Xen:

Without the correct repositories your host will have no idea where to get Xen from use the following command to install the Xen Repos:

yum install centos-release-xen

Once you have your repositories setup you can use the following command to install Xen and Libvirt:

yum install xen libvirt-daemon libvirt virt-install

Configure Grub:

You will need to configure Grub to make it boot the Xen kernel so edit “/boot/grub/grub.conf” with the newer versions of CentOS and Xen, you may not even have to modify this file. If you want to take CPUs and RAM away from the host you want it to look something like this: (the host will only be able to see 1cpu and 1gb of RAM, leaving the rest totally for virtual machines)

title CentOS (3.18.21-16.el6.x86_64)
  root (hd0,0)
  kernel /xen.gz dom0_max_vcpus=1 dom0_vcpus_pin dom0_mem=768M,max:1024M loglvl=all guest_loglvl=all
  module /vmlinuz-3.18.21-16.el6.x86_64 ro root=UUID=b2469440-dec3-4208-a460-d5d391cd58da rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet crashkernel=auto
  module /initramfs-3.18.21-16.el6.x86_64.img

Bridging:

The next step is to configure network bridges so that your virtual machines can access the host’s network. The files described in this section should all be created in: “/etc/sysconfig/network-scripts/” so you may just want to “cd” there now.

Create a network bridge:

File: ifcfg-br0

DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
IPADDR=172.30.0.49
NETMASK=255.255.255.0
GATEWAY=172.30.0.1
ONBOOT=yes

Set your eth device to be part of the new bridge:

File: ifcfg-eth0

DEVICE=eth0
HWADDR=00:1C:C4:A7:E7:BC
TYPE=Ethernet
UUID=378135e2-ea00-4889-b324-d37c78538aee
ONBOOT=yes
NM_CONTROLLED=no
BRIDGE=br0

If you want a bridge where the host doesn’t have access to that particular network, you can make a bridge like this: (notice how the host does NOT have an IP address)

File: ifcfg-br1

DEVICE=eth1
HWADDR=00:1C:C4:A7:E7:BA
TYPE=Ethernet
UUID=1b83a22e-e584-4e3f-9b6f-e4923a841369
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
BRIDGE=br1
DEFROUTE=no

Again you would need to assign and eth device to the bridge to make it able to talk on the network:

File: ifcfg-eth1

DEVICE=eth1
HWADDR=00:1C:C4:A7:E7:BA
TYPE=Ethernet
UUID=1b83a22e-e584-4e3f-9b6f-e4923a841369
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
BRIDGE=br1
DEFROUTE=no

Finally if you just make a bridge using either of the above bridge configurations, you can make a “virtual” network where the VMs and the host can communicate but it wont be accessible from outside the host.

I hope this quick little guide to configuring Xen on CentOS helped!

1 Comments

  • L0krin (#)
    July 19th, 2016

    If you don’t need the Xen host to have Internet access, sometimes its a good idea to not assign an IP to the bridge interface, this will protect your host because no one would be able to access the host itself on that bridge.

You must be logged into post a comment.