This is my notes for the creation of a Centos 7 domU on a Debian 7 dom0. I did not manage to generate a Centos 7 system with the xen-tools, so I’ve decided to install it from scratch, with the official Centos 7 installation iso.
Requirements:
-
I assume you already have a working/test Debian 7 dom0
-
the qemu packages must be installed for the HVM mode
(dom0) # apt-get install qemu -
the package kpartx, in order to mount the system disk and modify the boot configuration
(dom0) # apt-get install kpartx
Create the LVs
We create 2 logical volumes in the volume group domU
(dom0) # lvcreate -L512M -n test-centos-7-swap domU
(dom0) # lvcreate -L10G -n test-centos-7-disk domU
Download the Centos 7 installation iso
(dom0) # cd /data
(dom0) # wget http://centos.mirror.root.lu/7/isos/x86_64/CentOS-7-x86_64-DVD-1503-01.iso
Create the domain config, boot the installation iso in HVM mode and use vnc as the graphical backend.
(dom0) # vim /etc/xen/test-centos-7.cfg
vcpus = '1'
memory = '512'
disk = [
'phy:/dev/domU/test-centos-7-disk,xvda,w',
'phy:/dev/domU/test-centos-7-swap,xvdb,w',
'file:/data/CentOS-7-x86_64-DVD-1503-01.iso,hdc:cdrom,r'
]
boot='dc'
name = 'test-centos-7'
vif = [ 'ip=10.74.5.45,mac=00:16:AB:CD:74:EE,bridge=breth1' ]
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
kernel = "hvmloader"
builder = 'hvm'
vfb = [ "type=vnc, vncpasswd=, vnclisten=0.0.0.0" ]
Start the domU and connect the the vnc server
(dom0) # xm create test-centos-7.cfg
(laptop)$ vncviewer 10.74.6.4:0
Start the installation as usual.
…

In the “installation destination” part, select both disks (xvda and xvdb) and create the partitions manually.

Use “standard partitions”, and create an ext4 partition on /dev/xvda and a swap partition on /dev/xvdb.
Using a standard ext4 partition will permit to boot the domU using pygrub.
…
…

Configure the network interface and proceed with the installation.
…

At this point, if you encounter the error "'DiskDevice' object has no attribute disk",
check the disks names in the xen domU configuration, it must be xvda, xvdb, etc.
The installer does not accept xvda1, xvda2, …
At the end of the installation, press reboot, and destroy the domU.
(dom0) # xm destroy test-centos-7
Create the pygrub configuration
At this point, we want to boot the domU using pygrub, you can test pygrub on the system logical volume:
(dom0) # pygrub /dev/domU/test-centos-7-disk
...
"couldn't find bootloader config file in the image provided."
For some reasons, the pygrub version provided with Debian 7 can’t find/parse the grub 2 configuration.
My workaround is to create a grub 1 configuration file (/etc/grub/menu.lst),
and a kernel post installation script, to ensure that the domU will always boot on the latest installed kernel.
(dom0) # kpartx -av /dev/domU/test-centos-7-disk
(dom0) # mount /dev/mapper/domU-test--centos--7--disk1 /mnt/
(dom0) # vim /mnt/boot/grub/menu.lst
default 0
title CentOS Linux 7
root (hd0,0)
kernel /boot/vmlinuz root=/dev/xvda1 ro crashkernel=auto
initrd /boot/initramfs
(dom0) # cd /mnt/boot
(dom0) # ln -sf initramfs-3.10.0-229.4.2.el7.x86_64.img initramfs
(dom0) # ln -sf vmlinuz-3.10.0-229.4.2.el7.x86_64 vmlinuz
(dom0) # vim /mnt/etc/kernel/postinst.d/99-kernel-links.sh
#! /bin/sh
KERNEL_VERSION="$1"
ln -sf /boot/initramfs-${KERNEL_VERSION}.img /boot/initramfs
ln -sf /boot/vmlinuz-${KERNEL_VERSION} /boot/vmlinuz
(dom0) # chmod +x /mnt/etc/kernel/postinst.d/99-kernel-links.sh
(dom0) # umount /mnt
Now, pygrub should find the grub configuration
(dom0) # pygrub /dev/domU/test-centos-7-disk
Using <class 'grub.GrubConf.GrubConfigFile'> to parse /boot/grub/menu.lst
linux (kernel /var/run/xend/boot/boot_kernel.me6ouM)(ramdisk /var/run/xend/boot/boot_ramdisk.gMOGfE)(args "root=/dev/xvda1 ro crashkernel=auto ")
Modify the xen domU configuration
You can now boot the system using this minimal configuration file
(dom0) # vim /etc/xen/test-centos-7.cfg
bootloader = '/usr/bin/pygrub'
vcpus = '1'
memory = '512'
disk = [
'phy:/dev/domU/test-centos-7-disk,xvda,w',
'phy:/dev/domU/test-centos-7-swap,xvdb,w',
]
name = 'test-centos-7'
vif = [ 'ip=10.74.5.45,mac=00:16:AB:CD:74:EE,bridge=breth1' ]
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
(dom0) # xm create test-centos-7.cfg
Test your system
Connect to this new domU, update the packages and ensure that the links /boot/vmlinuz and /boot/initramfs are up-to-date
(domU) # ls -la /boot
(domU) # yum update
(domU) # ls -la /boot
