Setting up RHEL5,6,7 XEN guests

warning: this guide is for legacy RHEL, see here for running an up-to-date RHEL guest


RHEL5,6,7 kernels are PV-capable (not PVH), so we’re good already.

mkdir -p /data/kernels/centos/
cd /data/kernels/centos/


# MD5 for v7
# bfabcfc71b255f82633a516e2f9bc441  initrd.img
# ee1ce5fdeac00b192df50a9bb89904fc  vmlinuz

# MD5 for v6
# 00558f12fc3607d12ea7bfb8ef10e2d7  initrd.img
# 498f960dcd531dcb7e34144451a30cc6  vmlinuz

as for RHEL5 you would need to grab it from some archive.



mkdir -p /root/guests/centos/
cd /root/guests/centos/

dd if=/dev/zero of=centos.disk bs=1GB count=0 seek=10

Booting RHEL5,6,7 installers (XEN/PV not PVH)

vi centos

kernel = "/data/kernels/centos/vmlinuz"
ramdisk = "/data/kernels/centos/initrd.img"

name = "centos"
vcpus = 3
maxvcpus = 8
memory = 7168
disk = ['file:/root/guests/centos/centos.disk,xvda,w']
vif = [ 'bridge=br0, vifname=centos.0' ]

when it asks for a mirror e.g. for RHEL6


once finished, you’re ready to grab the kernel and ramdisk from the first partition of the vdisk (/boot/) e.g. for RHEL6

losetup --find --partscan --show centos6.disk
ls -lF /dev/loop0*
mkdir lala/
mount /dev/loop0p1 lala/
cp lala/vmlinuz-2.6.32-754.el6.x86_64 /data/kernels/centos6/
cp lala/initramfs-2.6.32-754.el6.x86_64.img /data/kernels/centos6/
cp lala/grub/menu.lst /data/kernels/centos6/
umount lala/
rmdir lala/
losetup -d /dev/loop0

and finish-up as such e.g. for RHEL6

kernel = "/data/kernels/centos6/vmlinuz-2.6.32-754.el6.x86_64"
ramdisk = "/data/kernels/centos6/initramfs-2.6.32-754.el6.x86_64.img"
root = "/dev/mapper/VolGroup-lv_root ro rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD console=hvc0  KEYTABLE=us rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root rd_NO_DM rhgb quiet"

Some additional Anaconda installer (no kickstart here) settings that might help you speed-up the process e.g. for RHEL7

extra="console=hvc0 net.ifnames=0 biosdevname=0 mitigations=off ifname=eth0 bootdev=eth0 inst.repo= inst.kdump_addon=off noipv6 selinux=0 inst.text dhcp"

Ready to go

xl create centos -c

RHEL7+ text mode Anaconda

navigate through the virtual windows


this takes a while

Performing post-installation setup tasks

RHEL5 text-mode install

web site
directory 5.11/os/x86_64/
text mode
initialize disk: yes
default partitioning layout
package selection: uncheck everything

Kernel & ramdisk fixup

once rebooting

xl console $guest
xl des $guest

losetup --find --partscan --show $guest.disk
ll /dev/loop0*
mkdir lala
mount /dev/loop1p1 lala
cat lala/grub/menu.lst
cp lala/vmlinuz-3.10.0-1062.el7.x86_64 /data/kernels/centos7/
cp lala/initramfs-3.10.0-1062.el7.x86_64.img /data/kernels/centos7/
ln -sf vmlinuz-3.10.0-1062.el7.x86_64 /data/kernels/centos7/vmlinuz
ln -sf initramfs-3.10.0-1062.el7.x86_64.img /data/kernels/centos7/initramfs
#cp lala/vmlinuz-2.6.18-398.el5xen /data/kernels/centos5/
#cp lala/initrd-2.6.18-398.el5xen.img /data/kernels/centos5/
#ln -s
#ln -s
umount lala
losetup -d /dev/loop1   
losetup -a
vi $guest

RHEL7 (w/o the .img)

ramdisk = "/data/kernels/centos7/initramfs"
root = "/dev/xvda3"
#extra = "console=hvc0"

RHEL5 (ramdisk according to the symlink w/o the ending .img)

ramdisk = "/data/kernels/centos5/initrd"
root = "/dev/VolGroup00/LogVol00"
#root = "/dev/xvda1 ro"
extra = "console=xvc0"
#extra = "init=/bin/bash"


There is also the pvgrub alternative.

Ready to go

xl create $guest -c

once installation is finished it will reboot. you need to kill that guest and disable install params you defined

xl des centos7
vi centos7


xl create centos7 -c

setup a few things for your template e.g.

    systemctl stop firewalld
    systemctl disable firewalld
    systemctl stop polkit
    systemctl disable polkit
yum update

yum install net-tools

yum install wget
rpm -ivh epel-release-latest-7.noarch.rpm

    cat >> /etc/hosts <<EOF
$ip $host
$gw gw

    echo linstor3 > /etc/hostname
    echo GATEWAY=$gw > /etc/sysconfig/network
    ln -s /etc/sysconfig/network-scripts/ifcfg-eth0 /root/ifcfg-eth0
    vi ifcfg-eth0


and proceed with RHEL7 post-installation


xvda vs xvda1 issue

           | Traceback (most recent call first):         ^ |                
           |   File                                      # |                
           | "/tmp/treedir.6201/instimage/usr/lib/anaco  : |                
           | nda/", line 1007, in           : |                
           | hasGptLabel                                 : |                
           |     disk = diskset.disks[device]            : |                
           |   File                                      : |                
           | "/tmp/treedir.6201/instimage/usr/lib/anaco  : |                
           | nda/", line 1081, in           : |                
           | sanityCheckAllRequests                      : |                
           |     elif self.hasGptLabel(diskset, dev):    : |                
           |   File "/usr/lib/anaconda/",     v |               


Seen with RHEL6 and RHEL7

xc_dom_guest_type: image not capable of booting inside a HVM container: Invalid kernel


xc: error: panic: xc_dom_elfloader.c:64: xc_dom_guest_type: image not capable of booting inside a HVM container: Invalid kernel

==> You are trying to launch the guest as PVH. Try as PV instead.

RHEL7 resources

Creating and installing a CentOS 5 domU instance

Building a Xen Guest Root Filesystem using yum and rpm

Chapter 32. Xen configuration files

booting options

Installing in Text Mode

Booting the Installation on 64-bit AMD, Intel, and ARM systems

Kickstart Installations

RHEL5 resources

How to Install Paravirtualized CentOS 7 DomU on Xen

Anaconda Boot Options

Chapter 22. Boot Options

CentOS 7 Xen PV guests failing to boot with kernel 3.10.0-693.17.1.el7

Problems with Centos 7 new kernel and XEN VM (Solved)