home | tech | misc | code | bookmarks (broken) | contact | README

Xen: Setup Linux as domU

Last update to this page was in 2018-09-13.

We are using dom0 host configured with NetBSD 8.0. For more information how to setup dom0, check Xen setup in NetBSD.

Possible guest configurations

Before starting, it is good to know that a domU guest can be installed in different modes. In this guide we are going to initial setup of CentOS Linux as PV and HVM guests.

What's the difference between PV (Paravirtualized) and HVM? For this, I recommend you to take a look at the Xen Project Software Overview page, section Guest Types, but, in summary, in PV mode you need to run a modified version of the kernel for your domU system, but it doesn't require any special processor support. In HVM mode, you can run an unmodified operating system as domU (so, it is possible to run Windows), but it requires special instruction in your processor.

You may want to run your guests as HVM to save you some trouble, but there may be are advantages running them as paravirtualized guests.

Installing CentOS as Paravirtualized (PV) domU

First, it is important to note that CentOS doesn't support paravirtualization since version 7.4, as noted by smart prgmr people (note that they point to an alternate kernel that can support PV mode). So these instructions work for older versions of CentOS. The one we are going to use in this section is version 6, but it may work for versions up to 7.3.

Most of the tips I got for this section are here How to Install Paravirtualized CentOS 7 DomU on Xen.

First, download CentOS 6 kernel and initrd. Links below worked at the time I was writing this:

# mkdir -p /vm/centos6
# cd /vm/centos6
# wget http://mirror.globo.com/centos/6/os/x86_64/isolinux/vmlinuz
# wget http://mirror.globo.com/centos/6/os/x86_64/isolinux/initrd.img

For now, we are going to cover how to setup the virtual machine in a image file. It is possible to use a separated partition for it, improving performance, but it is beyond the scope of this guide. Create the image:

# dd if=/dev/zero of=centos6.img bs=1m seek=20000 count=1

We created a 20 GB image, but in sparse file format, with the seek operand.

We now create file centos6.cfg with the following content:

disk=['file:/vm/centos6/centos6.img,xvda,w' ]

You can now just instruct Xen to create our virtual machine:

# xl create centos6.cfg

And to access its console, type:

# xl console centos6