<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://t2bwiki.iihe.ac.be/index.php?action=history&amp;feed=atom&amp;title=Manage_XEN</id>
	<title>Manage XEN - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://t2bwiki.iihe.ac.be/index.php?action=history&amp;feed=atom&amp;title=Manage_XEN"/>
	<link rel="alternate" type="text/html" href="https://t2bwiki.iihe.ac.be/index.php?title=Manage_XEN&amp;action=history"/>
	<updated>2026-04-20T09:52:43Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://t2bwiki.iihe.ac.be/index.php?title=Manage_XEN&amp;diff=171&amp;oldid=prev</id>
		<title>Maintenance script: Created page with &quot;   === Introduction ===  This howto describes how you can create a Scientific Linux 5 Xen domU instance, without using &#039;&#039;&#039;virt-manager&#039;&#039;&#039;, or its console variant &#039;&#039;&#039;virt-i...&quot;</title>
		<link rel="alternate" type="text/html" href="https://t2bwiki.iihe.ac.be/index.php?title=Manage_XEN&amp;diff=171&amp;oldid=prev"/>
		<updated>2015-08-26T12:28:46Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;   === Introduction ===  This howto describes how you can create a Scientific Linux 5 Xen domU instance, without using &amp;#039;&amp;#039;&amp;#039;virt-manager&amp;#039;&amp;#039;&amp;#039;, or its console variant &amp;#039;&amp;#039;&amp;#039;virt-i...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
This howto describes how you can create a Scientific Linux 5 Xen domU instance, without using &amp;#039;&amp;#039;&amp;#039;virt-manager&amp;#039;&amp;#039;&amp;#039;, or its console variant &amp;#039;&amp;#039;&amp;#039;virt-install&amp;#039;&amp;#039;&amp;#039;. Usually, instances require more customization than these tools provide, so it is often better to make instances using the tools that lie underneath. The last section of this howto describes how you can perform the same steps with virsh, a generic tool for management of virtualized domains.&lt;br /&gt;
&lt;br /&gt;
To clear up some terminology that is often confusing to new Xen users: dom0 is the privileged administrative domain of which only one can run. domU is an unprivileged domain, of which many can run at the same time. Although it is an incorrect analogy, it often helps to think of dom0 as the host system, and domU as a guest system.&lt;br /&gt;
&lt;br /&gt;
We recommend to disable SELinux to avoid problem accessing images files located in non standard places.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Installing XEN ===&lt;br /&gt;
Check whether XEN is installed on your running kernel.&lt;br /&gt;
Otherwise install it: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  yum install kernel-xen xen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Make sure that the xen-enabled kernel is the default one. Modify the file /etc/grub.conf if required.&lt;br /&gt;
&lt;br /&gt;
=== Creating an image ===&lt;br /&gt;
&lt;br /&gt;
The following command will create a /var/lib/xen/mailserver.img file of 2048MB, although the actual data blocks are allocated in a lazy fashion:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# dd if=/dev/zero of=/var/lib/xen/images/mailserver.img oflag=direct bs=1M seek=2047 count=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# dd if=/dev/zero of=/var/lib/xen/images/mailserver.img oflag=direct bs=1M count=2048&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will avoid data block allocation problems if the volume that holds the image is full.&lt;br /&gt;
&lt;br /&gt;
To avoid issues with SElinux later, check the SElinux context of the images:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  ls -Z /var/lib/xen/images/mailserver.img&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should give eg &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-rw-r--r--  root root root:object_r:xen_image_t        /var/lib/xen/images/mailserver.img&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing a Xen configuration file for the installation ===&lt;br /&gt;
&lt;br /&gt;
Xen uses a configuration file per domain. The configuration for the domain will be slightly different during the installation, because we have to provide installation kernels, and possibly some boot parameters. You will need a domU installation initrd image and kernel. Depending on the machine architecture, both can be downloaded from:&lt;br /&gt;
&lt;br /&gt;
[http://linuxsoft.cern.ch/scientific/50/i386/images/xen/ SL5 i386 XEN images]&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
[http://linuxsoft.cern.ch/scientific/50/x86_64/images/xen/ SL5 x86_64 XEN images]&lt;br /&gt;
&lt;br /&gt;
Same with older version of SLC:&lt;br /&gt;
[http://linuxsoft.cern.ch/cern/slc44/i386/images/SL/xen/ SLC44 i386 XEN images]&lt;br /&gt;
[http://linuxsoft.cern.ch/cern/slc45/i386/images/SL/xen/ SLC45 i386 XEN images]&lt;br /&gt;
[http://linuxsoft.cern.ch/cern/slc45/x86_64/images/SL/xen/ SLC45 x86_64 XEN images]&lt;br /&gt;
&lt;br /&gt;
You can put them in some sensible directory, and rename them appropriately. In this example, the kernel and initrd image will be named /boot/vmlinuz-xen-install and /boot/initrd-xen-install.img respectively.&lt;br /&gt;
&lt;br /&gt;
Eg for SL50 i386, do&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
wget -O /boot/vmlinuz-xen-install http://linuxsoft.cern.ch/scientific/50/i386/images/xen/vmlinuz&lt;br /&gt;
wget -O /boot/initrd-xen-install.img http://linuxsoft.cern.ch/scientific/50/i386/images/xen/initrd.img&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With the images in place, you can create the installation configuration file, named /etc/xen/mailserver here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
kernel = &amp;quot;/boot/vmlinuz-xen-install&amp;quot;&lt;br /&gt;
ramdisk = &amp;quot;/boot/initrd-xen-install.img&amp;quot;&lt;br /&gt;
extra = &amp;quot;text&amp;quot;&lt;br /&gt;
name = &amp;quot;mailserver&amp;quot;&lt;br /&gt;
memory = &amp;quot;512&amp;quot;&lt;br /&gt;
disk = [ &amp;#039;tap:aio:/var/lib/xen/images/mailserver.img,xvda,w&amp;#039;, ]&lt;br /&gt;
vif = [ &amp;#039;bridge=xenbr0&amp;#039;, ]&lt;br /&gt;
vcpus=1&lt;br /&gt;
on_reboot = &amp;#039;destroy&amp;#039;&lt;br /&gt;
on_crash = &amp;#039;destroy&amp;#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may want to tune some of the parameters, like &lt;br /&gt;
*the amount of memory that is dedicated to the domU&lt;br /&gt;
*the name of the bridge, if you will be using a different bridge for this domU. Check if the bridge device is available with &amp;#039;&amp;#039;&amp;#039;ifconfig &amp;lt;name_of_bridge&amp;gt;&amp;#039;&amp;#039;&amp;#039;. For the example above use&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  ifconfig xenbr0  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Besides that, this configuration file uses a kickstart file to perform the installation automatically. This example explicitly uses a text installation. You can also perform the installation automatically by giving a kickstart file appended to the &amp;#039;extra&amp;#039; option.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Starting the installation ===&lt;br /&gt;
&lt;br /&gt;
With the installation configuration set up, you have to launch now the domU instance:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# xm create mailserver&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you configured this domU correctly, the installation will happily start. You can attach a console to the domU:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# xm console mailserver&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After the installation, the domU will be rebooted and destroyed (since that is the default action for reboots, we will change that later).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Post-install configuration ===&lt;br /&gt;
&lt;br /&gt;
Now that the installation is finished, this can be a good time to make a copy of the instance image to use as a template. At this point the SSH keys are not generated yet, making it easier to give each instance a unique set of SSH keys.&lt;br /&gt;
&lt;br /&gt;
The installation configuration should now be modified for non-install use. This is the modified configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
name = &amp;quot;mailserver&amp;quot;&lt;br /&gt;
memory = &amp;quot;256&amp;quot;&lt;br /&gt;
disk = [ &amp;#039;tap:aio:/var/lib/xen/images/mailserver.img,xvda,w&amp;#039;, ]&lt;br /&gt;
vif = [ &amp;#039;bridge=xenbr0&amp;#039;, ]&lt;br /&gt;
bootloader=&amp;quot;/usr/bin/pygrub&amp;quot;&lt;br /&gt;
vcpus=1&lt;br /&gt;
on_reboot = &amp;#039;restart&amp;#039;&lt;br /&gt;
on_crash = &amp;#039;restart&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, this new configuration is not using the kernel and initrd images anymore. Instead, it is using &amp;#039;&amp;#039;&amp;#039;pygrub&amp;#039;&amp;#039;&amp;#039; as a bootloader. &amp;#039;&amp;#039;&amp;#039;pygrub&amp;#039;&amp;#039;&amp;#039; will try to look for a partition holding a filesystem that contains the GRUB configuration in the virtual disk image. If a GRUB configuration was found, this will be used to boot a kernel. This is very handy, because this will allow you to use/manage kernels in the domU. If yum update pulls in a security updated kernel in the domU, it will automatically be used during the next boot of the domain.&lt;br /&gt;
&lt;br /&gt;
Another change is that we have changed how to handle crashes and reboots. You&amp;#039;ll usually want to reboot a domain if a crash or reboot occurs.&lt;br /&gt;
&lt;br /&gt;
With this configuration in place, you can test this domain:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# xm create mailserver&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have installed SSH, you can log in to that domain through SSH, or you can use the Xen console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# xm console mailserver&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now administrate the domain as a usual Linux machine. You can shut down the domain with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# xm shutdown mailserver&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information on the options that xm provides, please refer to the xm manual page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Automatically starting domains ===&lt;br /&gt;
&lt;br /&gt;
If you would like a domain to start automatically when the (dom0) system is started, move the domain configuration to the /etc/xen/auto directory. For instance:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mv /etc/xen/mailserver /etc/xen/auto&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will also shut down the domain properly when the system is shut down.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Special settings ===&lt;br /&gt;
&lt;br /&gt;
To add a new virtual network interface (first check if device ethX is unused and available with &amp;#039;&amp;#039;&amp;#039;ifconfig ethX&amp;#039;&amp;#039;&amp;#039;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/etc/xen/scripts/network-bridge start vifnum=1 bridge=xenbr1 netdev=eth1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This page has been inspired by this&amp;#039;&amp;#039;&amp;#039; [http://wiki.centos.org/HowTos/Xen/InstallingCentOSDomU HowTo]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{TracNotice|{{PAGENAME}}}}&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>