Setting up an RHEL/CentOS XEN guest

RHEL7 requirements

mkdir -p /data/kernels/centos7/
cd /data/kernels/centos7/
#wget https://mirror.yandex.ru/centos/7/os/x86_64/isolinux/vmlinuz
#wget https://mirror.yandex.ru/centos/7/os/x86_64/isolinux/initrd.img
wget https://mirror.yandex.ru/centos/7/os/x86_64/images/pxeboot/vmlinuz
wget https://mirror.yandex.ru/centos/7/os/x86_64/images/pxeboot/initrd.img

RHEL5 requirements

mkdir -p /data/kernels/centos5/
cd /data/kernels/centos5/
wget http://vault.centos.org/5.11/os/x86_64/images/xen/vmlinuz
wget http://vault.centos.org/5.11/os/x86_64/images/xen/initrd.img

Disk

guest=centos7tpl
mkdir /data/guests/$guest/
cd /data/guests/$guest/
dd if=/dev/zero of=$guest.disk bs=1G count=0 seek=5

RHEL7 guest

cat > $guest <<-EOF
kernel = "/data/kernels/centos7/vmlinuz"
ramdisk = "/data/kernels/centos7/initrd.img"
extra="inst.repo=https://mirror.yandex.ru/centos/7/os/x86_64/ inst.kdump_addon=off noipv6 selinux=0 inst.text console=hvc0 dhcp"
memory = 4096
name = "$guest"
vcpus = 16
disk = ['file:/data/guests/$guest/$guest.disk,xvda,w']
vif = [ 'bridge=xenbr0, vifname=$guest.0' ]
EOF
vi $guest

RHEL5 guest

cat > $guest <<-EOF
kernel = "/data/kernels/centos5/vmlinuz"
ramdisk = "/data/kernels/centos5/initrd.img"
memory = 4096
name = "$guest"
vcpus = 16
disk = ['file:/data/guests/$guest/$guest.disk,xvda,w']
vif = [ 'bridge=xenbr0, vifname=$guest.0' ]
EOF
vi $guest

Ready to go

xl create /data/guests/$guest -c

RHEL7 text mode Anaconda

navigate through the virtual windows

ESC TAB

this takes a while

Performing post-installation setup tasks

RHEL5 text-mode install

English
HTTP
IPv4 DHCP
web site http://vault.centos.org
directory 5.11/os/x86_64/
text mode
initialize disk: yes
default partitioning layout
...
package selection: uncheck everything
reboot

Kernel & ramdisk fixup

once rebooting

xl console $guest
^]
reset
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"

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 centos7tpl
vi centos7tpl

#ramdisk="..."
#extra="..."

xl create centos7tpl -c

setup a few things for your template e.g.

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

yum install net-tools

yum install wget
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm

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

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

NAME=eth0
DEVICE=eth0
IPADDR=x.x.x.x
PREFIX=24
ONBOOT=yes

and proceed with RHEL7 post-installation

RHEL5 troubleshooting

xvda vs xvda1 issue

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

RHEL7 resources

Creating and installing a CentOS 5 domU instance https://wiki.centos.org/HowTos/Xen/InstallingCentOSDomU

Building a Xen Guest Root Filesystem using yum and rpm https://www.virtuatopia.com/index.php/Building_a_Xen_Guest_Root_Filesystem_using_yum_and_rpm

Chapter 32. Xen configuration files https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/virtualization/chap-virtualization-xen_configuration_files

booting options

Installing in Text Mode https://docs.centos.org/en-US/centos/install-guide/Text_Installation_Intro-x86/

Booting the Installation on 64-bit AMD, Intel, and ARM systems https://docs.centos.org/en-US/centos/install-guide/Boot_x86/#chap-booting-installer-x86

Kickstart Installations https://docs.centos.org/en-US/centos/install-guide/Kickstart2/

RHEL5 resources

How to Install Paravirtualized CentOS 7 DomU on Xen https://www.systutorials.com/239895/install-paravirtualized-centos-7-domu-xen/

Anaconda Boot Options https://rhinstaller.github.io/anaconda/boot-options.html

Chapter 22. Boot Options https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/chap-anaconda-boot-options

CentOS 7 Xen PV guests failing to boot with kernel 3.10.0-693.17.1.el7 https://kevandrews.uk/centos-7-xen-pv-guests-failing-boot-kernel-3100-693171el7

Problems with Centos 7 new kernel and XEN VM (Solved) https://www.centos.org/forums/viewtopic.php?t=64859


NETHENCE | PUB | LAB