How to Install Paravirtualized CentOS 7 DomU on Xen

Posted on In Tutorial

This post introduces how to install a paravirtualized CentOS 7 DomU on Xen. The very common way of installing DomU does not work for CentOS 7. A little trick to set the repository and the network used by the VM should be used by adding a setting strings to the “extra=” field for this VM.

Note that this tutorials was tested with CentOS 7.2 (1511). The kernel in CentOS 7.4 seems have problems with Xen. Please check comments on some details.

To install the DomU VM, first download the pxeboot images from CentOS’s website at http://vault.centos.org/7.2.1511/os/x86_64/images/pxeboot/ (due to the problems of some later kernels with Xen, we use vault here to make sure it is a 7.2.1511 kernel).

The commands are (assume we are working in a directory of the VM `/home/xen/centos7/` ):

# wget http://vault.centos.org/7.2.1511/os/x86_64/images/pxeboot/vmlinuz
# wget http://vault.centos.org/7.2.1511/os/x86_64/images/pxeboot/initrd.img

Prepare the configuration file centos7.cfg used for the VM:

name="centos7install"
vcpus=4
memory=2048
disk=['file:/home/xen/centos7/vmdisk0,xvda,w' ]
vif=['bridge=xenbr0']
on_reboot="restart"
on_crash="restart"
kernel="/home/xen/centos7/vmlinuz"
ramdisk="/home/xen/centos7/initrd.img"
extra="ksdevice= inst.repo=http://vault.centos.org/centos/7.2.1511/os/x86_64/ ip=10.0.0.222::10.0.0.2:255.255.0.0:cento7:eth0:none nameserver=8.8.8.8"

Here, note the trick of adding the line

extra="ksdevice= inst.repo=http://vault.centos.org/centos/7.2.1511/os/x86_64/ ip=10.0.0.222::10.0.0.2:255.255.0.0:cento7:eth0:none nameserver=8.8.8.8"

Here 10.0.0.222 is the IP assigned to the VM and 10.0.0.2 is the gateway. You will need to change the parameters here according to your network environment for the VM.

Prepare the disk image for the VM in the VM’s directory:

# dd if=/dev/zero of=./vmdisk0 bs=1k seek=20480k count=1

Now, start the VM and it will starts to install itself,

# xl create -c centos7.cfg

Then, just follow the CentOS 7’s instructions to install and configure the VM.

Booted the kernel and starting to download the installation files:

Choose the installation interface (choose “Use text mode”):

Make the choices for various OS configurations:

Started to install packages:

Installation completes:

Boot the VM again **with a normal configuration file** as follows.

name="centos7"
vcpus=4
memory=2048
disk=['file:/home/xen/centos7/vmdisk0,xvda,w' ]
vif=['bridge=xenbr0']
on_reboot="restart"
on_crash="restart"
bootloader = "pygrub"

The key changes here are to remove the `kernel`, `ramdisk` and `extra` variables and setting `bootloader` to “pygrub”.

It works nicely now:

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

17 comments

  1. hi
    I just did what you explained but after installation what should I change in the vm config file to let it start normally ?
    thank you

    1. Was the panic from the Domain-0 or the DomU? To understand the problem, what’s your Domain-0’s environment (Xen version and kernel version) and any error messages printed / show?

  2. The kernel panic was from DomU itself, before it got to the install screen. The VM gets the message “Kernel panic – not syncing: Fatal exception” and gets into a reboot loop with that message a few times before the DomU stops altogether.

    It’s done this on a CentOS Dom0 running Xen 4.6 and a Debian Dom0 with is Xen 4.8.

    I’m testing this on an older laptop with a Core i5 2520 CPU that has full VM extensions enabled. It installs fine in full HVM mode.

    1. I see. I confirm the version I tested was CentOS 7.2.1511 on Xen 4.3. The current version on the FTP seem at least some 17xx one. It may have changed. I am not sure whether it works, you may try to delete the “extra” line.

      1. Eric, I got an idea to try these steps but go back to 7.2 using vault.centos.org to pull down the 7.2 pxe images and as the install path. That worked to install CentOS paravirtually. Then, I just updated to CentOS 7.4 (the current version) from there. The only issue is the default kernel for 7.4 doesn’t boot up in pygrub because of a flaw. So, while still on 7.2, I had to install the kernel from the centosplus repo, and then it worked. Or, you just run it as a paravirtual HVM and that will work, too.

        1. Thanks for the confirmation. Then I guess the kernel in CentOS 7.4 does not work well with Xen for para mode.

          As most hardware supports it, HVM based full virtualization may be performance well enough.

          1. From what I’ve read the HVM full virt mode works just as well performance wise since it runs its own paravirtual drivers. However, thanks for your input. Your steps worked well.

  3. As of this date the install fails after Anaconda starts with a series of exceptions that culminates with “ValueError: new value non-existent xfs filesystem is not valid as a default fs type”. This has been reported as a mismatch between vmlinuz and initrd.img, however at least for the pxeboot files that’s not the case. The problem appears to be a mismatch between the locked down version (vault.centos.org/7.2.1511) for these files vs. the repo specified in the “extra” line (http://mirror.centos.org/centos/7/os/x86_64/). Changing the repo url to http://vault.centos.org/centos/7.2.1511/os/x86_64/ fixes the problem

      1. And I should have opened my comment with a thank you!. This post is very much appreciated! You saved me a lot of time in bringing up RHEL guests.

  4. Thanks for the great write-up! I did this with a CentOS 7.5 domU running on a CentOS 6.11 dom0 (Xen 4.6.6).

    The one issue (and it’s one I’ve run into before but forgot about) is that the /boot partition is created with xfs by default. pygrub chokes on it in that environment. Changing the /boot partition to ext3 during install solves it.

    (Probably not the only way to solve it, but personally I don’t care whether that partition is ext3 or xfs, so might as well make it backwards compatible.)

    Hope that helps someone out!

    Scott

  5. Thanks for sharing this great workaround ;)
    This worked for me installing a fedora 28 paravirt domU on a Fedora 29 dom0 where the traditional virt-manager / virt-install method failed!

Leave a Reply

Your email address will not be published. Required fields are marked *