Note: I lost my original xen config files so I've created new ones here. I no longer have a xen system so I can't test them. Please let me know if the tutorial still works or not - Grant


A lot of this tutorial was stolen from my CentOS 5 Installation which in turn was stolen from the CentOS wiki. I've shortened and updated it for installing a CentOS 6 DomU. I just copy and paste all the indented lines into a root terminal and voila! a CentOS VM.

1. Creating an Virtual Disk Image

The first step is to create an disk image that will act as the VM hard drive. The following command will create a 4 GB sparse disk image named /srv/xen/centos6.img. A sparse file is created in such a way that the disk image doesn't actually take up the whole 4GB until you fill it up. If you'd like a larger (11GB) disk image substitute seek=10240 into the following line. I make my VMs nice and small so I can move them around easier. Making a disk image larger or adding a second drive later is easier than making it smaller or taking a drive away.


dd if=/dev/zero of=/srv/xen/centos6.img oflag=direct bs=1M seek=3800 count=1

2. Preparing the Xen configuration file for installation

Xen uses one configuration file per VM. We will start out with a config to do the install and replace it later with a config for normal operation. Now we download the install kernel, ramdisk and xen config file.

wget -O /boot/vmlinuz-xen6-install
wget -O /boot/initrd-xen6-install
wget -O /etc/xen/centos6




3. Starting the installation

A kickstart file holds instructions for automatic installation and is referenced in my xen config above. My example kickstart file is very minimal but is enough to get a working CentOS 6 VM.



Modifications: If you want to make changes to my kickstart files just download it from and store it on a web server that you manage. Then change the "extra =" line in /etc/xen/centos6 to point to your kickstart file.

Also if your xen system uses a different bridge name then xenbr0 you will need to change this in /etc/xen/centos6. Here's my line.

  • vif = [ 'bridge=xenbr0', ]

Now you can start the VM installation process.  After the installation, the VM will shut down.


xm create -c centos6


4. Post install configuration



Use wget to download the VM config file for normal operational use. This new config file no longer uses the dowloaded kernel and initrd images. Instead, it is using pygrub as a bootloader that acts like GRUB and uses the grub.conf file from inside the VM.  With this configuration in place, you can boot the VM with visible console.


wget -O /etc/xen/centos6
xm create -c centos6



Now that your CentOS 6 VM is running you can login. The password was automatically set by the kickstart file.

  • Username: root
  • Password: bogus



5. Add RPMforge Repository

I almost always install RPMforge. It is very stable and doesn't replace standard packages.

rpm --import
rpm -ivh

6. Backup our Virtual Disk Image


Before you start modifying the base CentOS image you should back it up.

cp -av /srv/xen/centos6.img /srv/xen/centos6-base.img


7. Start our CentOS VM Automatically


If you would like your VM to start automatically when the Host system boots make a link to /etc/xen/centos6 config file in /etc/xen/auto.


ln -s /etc/xen/centos6 /etc/xen/auto/centos6

This will also shut down the domain properly when the system is shut down.

8. Bugs

One issue I've had with this setup is getting the following error

  • Bringing up interface eth0:  Device eth0 has different MAC address than expected, ignoring.
  • [FAILED]

I'm looking into it but to solve it you just need to edit /etc/sysconfig/network-scripts/ifcfg-eth0 and delete the HWADDR line. Then you can request an IP address using dhclient.

dhclient eth0