特殊:Badtitle/NS100:XenVirtualMachine:修订间差异

来自Ubuntu中文
跳到导航跳到搜索
Oneleaf留言 | 贡献
无编辑摘要
Oneleaf留言 | 贡献
无编辑摘要
第1行: 第1行:
{{From|https://help.ubuntu.com/community/XenVirtualMachine}}
{{From|https://help.ubuntu.com/community/XenVirtualMachine}}
{{Languages|UbuntuHelp:XenVirtualMachine}}
{{Languages|UbuntuHelp:XenVirtualMachine}}
This page is mostly old junk, and the useful parts are being migrated to [http://help.ubuntu.com/community/Xen Xen].




Xen virtualization allows you to run other Operating Systems inside Ubuntu. These may be either specially modifed guest OSs (like Ubuntu or other Linux distros), or if your CPU has hardware support for virtualization it, unmodifed Operating Systems (like Windows).


Xen began as a research project at the [http://www.cl.cam.ac.uk/research/srg/netos/xen/ University of Cambridge].
[http://www.xensource.com XenSource] is a spinoff that's attempting to improve and market Xen to commercial users.  They also host a lot of useful documentation, much of it in the [http://wiki.xensource.com/xenwiki/ Xen Wiki].


== Installing Xen on Ubuntu ==
=== Using loopback-mounted-file ===


Since release 6.10 (Edgy Eft), Ubuntu contains packages for the xen virtualization technology. The packages can be found within the universe repository, a tutorial is available in /XenOnUbuntuEdgy
* Generate loopback file as sparse file (not written entirely to disk but filled on demand) (replace 'edgy.ext3' with whatever name you want for it, ie. 'system1.ext3':
<pre><nowiki>
sudo dd if=/dev/zero of=/usr/local/edgy.ext3 bs=1024k seek=4096 count=0 </nowiki></pre>
 
* Create filesystem within (replace 'edgy.ext3' with what the name you used in step 1):
<pre><nowiki>
sudo mkfs.ext3 /usr/local/edgy.ext3 </nowiki></pre>
 
Mkfs will tell you that this is no block device. Since you already know that (do you?) you can tell it to create the filesystem nevertheless. (so say Yes)
 
* Loopback mount filesystem (replace 'edgy' and 'edgy.ext3' with the name you used in step 1):
<pre><nowiki>
sudo mkdir /mnt/edgy
sudo mount /usr/local/edgy.ext3 /mnt/edgy -o loop </nowiki></pre>


Earlier Ubuntu releases required you to install Xen by other means.
Most often this would be from binary packages of Xen kernels and utilities made available by the Xen project.
There are two wiki pages: XenOnUbuntuBinaryInstall and [[UbuntuHelp:/XenOnUbuntuBreezy]].


Other interesting writeups about Xen on Ubuntu or other Linuxes:
* [http://cosi.clarkson.edu/docs/installingxen/xen-tutorial.html Installing Xen] from the Clarkson Open Source Institute, mostly about using Ubuntu
* [http://www.howtoforge.com/xen_3.0_ubuntu_dapper_drake Xen 3.0 on Dapper] at Howto forge


=== Xen 3.03 on Feisty ===
* Install edgy base into it (replace 'edgy' with the release-name (version) of ubuntu you want (dapper, edgy, feisty, etc), replace '/mnt/edgy' with the name you used in step 1):
32bit Host O/S & 32bit virtual host <code><nowiki> sudo debootstrap edgy /mnt/edgy </nowiki></code>


Go to XenVirtualMachine/XenOnUbuntuFeisty
64bit Host O/S & 64bit virtual host <code><nowiki> sudo debootstrap --arch amd64 edgy /mnt/edgy </nowiki></code>


* Give it the kernel modules (the module name depends on whether you use the desktop or server edition) (this implies you are installing the same release of ubuntu as you are currently running on the system as the host O/S, which is edgy throughout this example) (replace '/mnt/edgy' with what you used in step 1):
32bit Host OS & 32bit Virtual host: <code><nowiki>  sudo cp -a /lib/modules/2.6.19-4-generic/ /mnt/edgy/lib/modules/ </nowiki></code>


=== Xen 3.03 on Edgy ===
64bit Host OS & 64bit Virtual host: <code><nowiki>  sudo cp -a /lib/modules/2.6.19-4-generic-amd64/ /mnt/edgy/lib/modules/ </nowiki></code>


Go to XenVirtualMachine/XenOnUbuntuEdgy
* Change whatever you want to be changed before the first boot. Examples:


=== Xen 3.03 on Dapper ===
The network example below is somewhat confusing.  Basically, whatever your Host O/S's (pre-existing) IP address is, put that in for the gateway, and make sure that the 'netmask' and 'address' put the virtual host into the same broadcast group as the host o/s (simpler example: address: 192.168.1.222 netmask: 255.255.255.0 gateway: 192.168.1.111, the 222 is the virtual host, the 111 is the host o/s's actual IP).


My rationale is simple: I'm setting this sucker up using Dapper because it's a server, and I prefer the longer term of support (and stability) over having the lastest versions of things.  So even though Edgy makes it easier, Xen on Dapper seems to me to be a pretty sensible server setup.  Ideally I'll not be updating this until I'm changing the hardware again...
If you followed the directions above regarding the network configuration you can run the following command:


For the most part the Xen installation was guided by the writeup from Hoto Forge, referenced above.
<code><nowiki> sudo nano /etc/network/interfaces </nowiki></code>
A rough manual diff while it's fresh:
* used  the 6.06.1-server-install-i386 for base install; added a few tools (openssh-server, eg.)
* install was on a 3ware mirror pair, and I used a single 3G root (sda1) plus LVM - this changes names, which is trivial, and is IMHO far better than using looped files as in the base document
* used Xen 3.03 tarball instead of 3.01: unpacks to a directory named ''dist''
* iproute already installed; python ditto *or* was pulled in as a dep of twisted
* instead of symlinking libcrypto (as in XenOnUbuntuBinaryInstall), I installed libssl0.9.7
* used update-rc.d xend defaults 30 31 and update-rc.d xendomains defaults 31 30 - I took the use of defaults from one (rather than unnecessary magic number lists), and avoiding an already busy number area from the other.  At least on this install, 30 was free space...
* with 3.03, the hacks to create directories in /var/run seem not to be necessary.
* fixing the LOCKFILE path in xend's init script still seemed like a good idea; did it.


...and that brings us up to the point in the process where I'm ssh'd in and getting ready to setup a guest domain (again - this was the "do it right and take better notes" reinstall).  LATER: had to leave this for a while; came back, noticed 3.0.4 tarballs were online, gave that a try.  WARNING: 3.0.4's xend (or was it xendomain?) REQUIRES TLS.  Yep, the same thing that Xen itself doesn't like (using Dapper's glibc).  I am now, somewhat reluctantly, giving Edgy a spin, though having a shorter support lifetime for the Dom0 is really, really backwards from what I'd hoped for.  But with Xen's move to requiring TLS for its infrastructure, that seems better than supporting my own libc spin with nonegseg on Dapper.  Maybe by the time Edgy loses support KVM will be ready for production...
and enter the following information


== Creating Guest Systems and Running Them ==
<pre><nowiki>
cat /mnt/edgy/etc/network/interfaces
auto lo
iface lo inet loopback


''there are notes on this in the various Xen documents, each of which seems to include something that others omit.  A thorough cleanup could pull this (mostly Ubuntu version independent?) into one better version.  If things go well, I'll be doing some work on that as I get a server consolidation project going here... gotta learn the questions first so I can answer them :-)''
auto eth0
iface eth0 inet dhcp </nowiki></pre>


One thing I want to record before I lose track of it again is the section from the Sarge installation guide titled [http://www.debian.org/releases/stable/i386/apcs04.html.en Installing Debian GNU/Linux from a Unix/Linux System].  I had been trying to remember where I saw the neat trick of chrooting into the semi-installed system image to complete its setup - this is it.
otherwise do the following:


== Running Windows inside Xen ==
<pre><nowiki>
cat /mnt/edgy/etc/network/interfaces
auto lo
iface lo inet loopback


See /XenOnUbuntuEdgy for a tutorial howto setup xen on VT HArdware to run Windows. For ubuntu versions prior to 6.10 (Edgy Eft), the following document http://www.iku-ag.de/opensource/xen-on-sles.jsp for SuSE should also be adaptable to Ubuntu.
auto eth0
iface eth0 inet static
address 192.168.44.247
netmask 255.255.252.0
gateway 192.168.47.254 </nowiki></pre>


== Older documentation and Discussion ==
Then configure the rest of the files:


MarkChang: As of 10.03.2005, I can't get to the Clarkson mirror to get any of the debs for Xen. [they changed the name of the file, go up a directory ;) ] However, I have met with great success with a mostly-manual install. '''Documented in /XenOnUbuntuHoary'''
<pre><nowiki>
cat /mnt/edgy/etc/hosts
127.0.0.1      localhost
127.0.1.1      edgyvm </nowiki></pre>


MarkChang: Feb 26, 2006. In general, a Xen 3 on Breezy works fine. Basically the same as /XenOnUbuntuHoary. No need to build a new kernel if you don't really want to. Get the tarball install from the Xen site, and unpack it and follow the instructions.  Some notes:
** In some versions of the tarball, the instructions for the grub kernel are wrong. Here is what I use:
****
<pre><nowiki>
<pre><nowiki>
title  Xen 3.0 / XenLinux 2.6.12
cat /mnt/edgy/etc/hostname
root   (hd0,0)
edgyvm </nowiki></pre>
kernel  /boot/xen.gz dom0_mem=65536
 
module /boot/vmlinuz-2.6.12.6-xen0 root=/dev/sda1 ro
<pre><nowiki>
savedefault
cat /mnt/edgy/etc/fstab
boot
proc            /proc          proc    defaults        0      0
/dev/hda1      /              ext3    defaults,errors=remount-ro 0      1
</nowiki></pre>
 
* Umount the loopback partition
<pre><nowiki>
sudo umount /mnt/edgy </nowiki></pre>
 
* Configure the guest, create /etc/xen/edgy-guest.cfg
<pre><nowiki>
kernel = "/boot/vmlinuz-2.6.19-4-generic"
ramdisk = "/boot/initrd.img-2.6.19-4-generic"
builder='linux'
memory = 128
name = "edgy-guest"
vcpus = 1
vif = [ 'bridge=xenbr0' ]
disk = [ 'file:/usr/local/edgy.ext3,ioemu:hda1,w' ]
root = "/dev/hda1 ro"
</nowiki></pre>
 
''' Note: Change hda1 by sda1 if you are using some SATA or SCSI Controller '''
 
Note that root points to the virtual root partition of the domU and not of dom0. It is recommended to give each domU a swap partition, in such case your cfg-file may look as follows (don't forget to add it to the /etc/fstab of the virtual host, so it mounts it on boot-up):
<pre><nowiki>
disk = [ 'file:/usr/local/edgy.ext3,ioemu:hda1,w','phy:/dev/hda6,ioemu:hda2,w']</nowiki></pre>
 
* Now you can create your xen domain
<pre><nowiki>
sudo xm create edgy-guest.cfg </nowiki></pre>
 
* You can connect to the guest using the command below or any network based access that you install later on (openssh-server, vncserver, remote-X11, ...)
<pre><nowiki>
sudo xm console edgy-guest </nowiki></pre>
 
Use '''crtl + ]''' to get out of console.
 
If you logged in via '''putty''' use '''ctrl + 5''' to leave the domu-console.
 
 
== Hypervisor and dom0 ==
'''The host for virtualized machines and the priviledged first guest'''
 
* The Xen kernel packages currently do not create an initrd image when they are installed. (This will probably be changed in the future). To create an initrd image run the following command:
<pre><nowiki>
sudo mkinitramfs -o /boot/xen0-linux-2.6.17-6-generic-xen0.initrd.img 2.6.17-6-generic-xen0
</nowiki></pre>Respectively:
<pre><nowiki>
sudo mkinitramfs -o /boot/xen0-linux-2.6.17-6-server-xen0.initrd.img 2.6.17-6-server-xen0
</nowiki></pre>if you are using the Ubuntu server distribution.
 
 
* Now that the kernel and initrd is installed, you have to setup grub. Add the following to your /boot/grub/menu.lst:
<pre><nowiki>
title XEN/2.6.17
root (hd0,0)
kernel /boot/xen-3.0-i386-pae.gz
module /boot/xen0-linux-2.6.17-6-generic-xen0 root=/dev/xxx ro
module /boot/xen0-linux-2.6.17-6-generic-xen0.initrd.img
</nowiki></pre>
where xxx is the partition where your root is located. Edgy can use a new way of identifying you partitions by UUID. In this case, just use that syntax for root e.g. <code><nowiki>root=UUID=f5cf5b9a-ed1a-4d6a-a707-a606574e2b6f</nowiki></code>. You can obtain the UUIDs of your partitions using the command <code><nowiki>blkid</nowiki></code> (found in <code><nowiki>/sbin</nowiki></code>). If you are using the server edition, please make sure you select the right terms in the module lines (xen0-linux-2.6.17-6-server-xen0...).
Note: On amd64, use xen-3.0-amd64.gz instead of xen-3.0-i386.gz
 
Note: kernel and modules may need to have the /boot removed from them to get this to work. ie
<pre><nowiki>
kernel /xen-3.0-i386.gz
</nowiki></pre>
 
 
== domU ==
''' The guest machines running under the xen hypervisor'''
 
Xen-tools can set up Ubuntu, Debian, CentOS systems, and also any other system if you give it a proper tarball.
 
A domU guest system can be built using the same kernel image that was used for dom0.
* Decide whether to use a '''loopback-mounted''' file or a '''raw partition''' for a clients filesystem.
 
=== use loopback-mounted-file ===
* In case of loopback, proceed like:
*** Generate loopback file as sparse file (not written entirely to disk but filled on demand:
<pre><nowiki>
sudo dd if=/dev/zero of=/usr/local/diskimage-guest.ext3 bs=1024k seek=4096 count=0 </nowiki></pre>
*** Create filesystem within:
<pre><nowiki>
sudo mkfs.ext3 /usr/local/diskimage-guest.ext3 </nowiki></pre> Mkfs will tell you that this is no block device. Since you already know that (do you?) you can tell it to create the filesystem nevertheless.
*** Loopback mount filesystem:
<pre><nowiki>
sudo mount /usr/local/diskimage-guest.ext3 /mnt -o loop </nowiki></pre>
*** Install debootstrap:
<pre><nowiki>
sudo apt-get install debootstrap </nowiki></pre>
*** Install edgy base into it:
<pre><nowiki>
sudo debootstrap edgy /mnt </nowiki></pre>
*** Give it the kernel modules (the module name depends on whether you use the desktop or server edition)
<pre><nowiki>
sudo cp -a /lib/modules/2.6.17-6-generic-xen0/ /mnt/lib/modules </nowiki></pre>
*** Change whatever you want to be changed before the first boot (/mnt/etc/apt/sources.list, /mnt/etc/network/interfaces, /mnt/etc/hostname, /mnt/etc/hosts)
*** Unmount
<pre><nowiki>
sudo umount /mnt </nowiki></pre>
*** Configure the guest, create /etc/xen/edgy-guest.cfg
<pre><nowiki>
kernel = "/boot/xen0-linux-2.6.17-6-generic-xen0"
ramdisk = "/boot/xen0-linux-2.6.17-6-generic-xen0.initrd.img"
builder='linux'
memory = 128
name = "edgy-guest"
vcpus = 1
vif = [ 'bridge=xenbr0' ]
disk = [ 'file:/usr/local/diskimage-guest.ext3,ioemu:hda1,w' ]
root = "/dev/hda1 ro"
</nowiki></pre> Note that root points to the virtual root partition of the domU and not of dom0. It is recommended to give each domU a swap partition, in such case your cfg-file may look as follows:
<pre><nowiki>
disk = [ 'file:/usr/local/diskimage-guest.ext3,ioemu:hda1,w','phy:/dev/hda6,ioemu:hda2,w']</nowiki></pre>
* Give it a try
* First start xend if it is not already started:
<pre><nowiki>
xend start </nowiki></pre>
 
* Now you can create your xen domain
<pre><nowiki>
sudo xm create edgy-guest.cfg </nowiki></pre>
* You can connect to the guest using
<pre><nowiki>
sudo xm console edgy-guest </nowiki></pre> or any network based access that you install later on (ssh or vnc or remote-X11)
 
 
=== use raw partition ===
 
* In case of a raw partition you want to use we need to create a file-system on it first.
*** If e.g /dev/hda6 is our raw unformated partiton create a ext3-filesystem:
<pre><nowiki>
mkfs -t ext3 /dev/hda6 </nowiki></pre>
*** The next step is to create a mountpoint and to mount it:
<pre><nowiki>
sudo mkdir /media/hda6 && sudo mount /dev/hda6 /media/hda6 </nowiki></pre>
*** All what follows now is ''almost'' identical to "use loopback-mounted-file"
*** Install edgy base into it:
<pre><nowiki>
sudo debootstrap edgy /media/hda6 </nowiki></pre>
*** Give it the kernel modules:
<pre><nowiki>
sudo cp -a /lib/modules/2.6.17-6-generic-xen0/ /media/hda6/lib/modules </nowiki></pre>
*** Change whatever you want to be changed before the first boot (/media/hda6/etc/apt/sources.list, /media/hda6/etc/network/interfaces, /media/hda6/etc/hostname, /media/hda6/etc/hosts)
*** Unmount
<pre><nowiki>
sudo umount /media/hda6 </nowiki></pre>
*** Configure the guest, create /etc/xen/edgy-guest.cfg
<pre><nowiki>
kernel = "/boot/xen0-linux-2.6.17-6-generic-xen0"
ramdisk = "/boot/xen0-linux-2.6.17-6-generic-xen0.initrd.img"
builder='linux'
memory = 128
name = "edgy-guest"
vcpus = 1
vif = [ 'bridge=xenbr0' ]
disk = [ 'phy:/dev/hdX,hda1,w' ]
root = "/dev/hda1 ro"
</nowiki></pre> Note that root points to the virtual root partition of the domU and not of dom0. It is recommended to give each domU a swap partition, in such case your cfg-file may look as follows:
<pre><nowiki>
disk = [ 'phy:/dev/hdXX,hda1,w','phy:/dev/hdXY,hda2,w']</nowiki></pre>
* Give it a try
* First start xend if it is not already started:
<pre><nowiki>
xend start </nowiki></pre>
 
* Now you can create your xen domain
<pre><nowiki>
sudo xm create edgy-guest.cfg </nowiki></pre>
* You can connect to the guest using
<pre><nowiki>
sudo xm console edgy-guest </nowiki></pre> or any network based access that you install later on (ssh or vnc or remote-X11)
 
Especially if you want to set up a larger number of virtual machines, it's strongly recommended to set up LVM and use logical volumes for your virtual machines.
 
 
 
 
 
 
== Installing DomU w/ debootstrap ==
 
First, setup and configure lvm, create an ext3 and swap partition in lvm, and mount your lvm partition to /xen.
 
<code><nowiki>apt-get install debootstrap</nowiki></code>
 
I prefer to install from CD, as it's faster. Mount your CD-Rom to /media/cdrom, and mount your future domU root partition to /xen
 
<pre><nowiki>
debootstrap dapper /xen file:/media/cdrom</nowiki></pre>
 
You should see lots of I: messages, and finally the prompt. Change directories to the root directory of your new filesystem.
 
=== Xen configuration options ===
 
Using your favorite editor (back in Dom0), create /etc/xen/dom1.cfg with the following text
 
<pre><nowiki>kernel = "/boot/vmlinuz-2.6-xen"
memory = 128
name = "dom1"
vif = [ '' ]
dhcp = "dhcp"
disk = ['phy:/dev/xen_lvm/dom1,hda1,w','phy:/dev/xen_lvm/dom1_swap,hdb1,w']
root = "/dev/hda1 ro"
extra = "4"
</nowiki></pre>
 
=== Create a DomU ===
 
<code><nowiki>xm create dom1.cfg -c</nowiki></code>
 
Login with root, no password (you want to change that!)
 
=== Changes Necessary on the DomU's Filesystem ===
<code><nowiki>mv ./lib/tls ./lib/tls.disabled</nowiki></code>
 
in ./etc/network/interfaces (change the relevant numbers)
<pre><nowiki>auto lo
iface lo inet loopback
 
auto eth0
iface eth0 inet static
address 192.168.3.101
netmask 255.255.255.0
network 192.168.3.0
broadcast 192.168.3.255
gateway 192.168.3.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 1.2.3.4 1.2.3.5</nowiki></pre>
 
 
Copy the Dom0's sources list: <code><nowiki>cp /etc/apt/sources.list ./etc/apt/sources.list</nowiki></code> and edit them if you wish.
 
 
In ./etc/fstab
 
<pre><nowiki># /fstab: static file system information.
#
# <file system> <mount point>  <type>  <options>      <dump>  <pass>
proc            /proc          proc    defaults        0      0
/dev/hda1      /              ext3    defaults,errors=remount-ro 0      1
/dev/hdb1      none            swap    sw              0      0</nowiki></pre>
 
<code><nowiki>umount /dev/xen_lvm/dom1</nowiki></code> (we don't want two operating systems writing to the same partition!)
 
Locale setup:
 
The locale isn't set up properly by default. Resolve this by:
<pre><nowiki>
Install base packages for your language:
apt-get install language-pack-en-base
 
Install/Reconfigure localeconf via either:
apt-get install localeconf
dpkg-reconfigure localeconf
 
*** Manage locale configuration files with debconf? -> yes
*** Please select the default system locale. -> Your locale. Mine is en_US ISO-8859-1 for example.
*** Select the environment settings that should override the default locale.  -> Select All
*** In the following dialogs always select what you set for your locale above.
 
Install/reconfigure locales:
apt-get install locales
dpkg-reconfigure locales
 
*** Here, use the same locale you used in the localeconf setup.
</nowiki></pre>
 
Setting up your hostname
 
<pre><nowiki>
Manually edit /etc/hostname with your domU hostname.
Manually edit /etc/hosts (If you used debootstrap, you need to set this file up from scratch.)
(set the 127.0.0.1 host in /etc/hosts to sync with the host in /etc/hostname)
</nowiki></pre>
 
At this point you want to set up sshd, so you can log into your new virtual machine remotely!
You are ready!
 
=== lib tls error ===
 
This should only be on older versions of Ubuntu, or on domU guests maybe?
 
If you receive a large warning message during boot-up about /lib/tls, you may do one of the following:
* <code><nowiki>mv /lib/tls /lib/tls.disabled</nowiki></code> (easy, but the issue may crop up again after an upgrade)
* [http://wiki.xensource.com/xenwiki/DebianTlsLibcDiversion Divert Xen using a Script] (This makes sure upgrades don't put /lib/tls back again.
* [http://wiki.xensource.com/xenwiki/UbuntuDapperHowTo Build your own glibc] (Instructions from XenSource's Wiki)
 
Note: Disabling /lib/tls gives significantly poor performance for glibc. [http://www.mail-archive.com/[email protected]/msg04668.html Find a way to install a Xen-friendly glibc]. Removing /lib/tls is disabling the thread-local storage (tls) handling features of glibc by hiding them.
 
=== libcrypto error ===
 
Probably only on older versions of Ubuntu.
 
If when starting xend, you get the error: blktapctrl: error while loading shared libraries: libcrypto.so.0.9.7: cannot open shared object file: No such file or directory
Figure out the version of libcrypto you have:
 
<code><nowiki>ls /usr/lib/libcrypto.so.*</nowiki></code>
 
for example :
 
/usr/lib/libcrypto.so.0.9.8
 
Make a symbolic link to it:
 
<code><nowiki>ln -s /usr/lib/libcrypto.so.0.9.8 /usr/lib/libcrypto.so.0.9.7</nowiki></code>
 
=== ethx missing ===
When porting a physical system to a xen image file, eth0 was missing.  Xen assigned eth2 as the first network interface.  To correct this issue comment out  eth0  in /etc/iftab. In fact this also happens if you move an installation to another hardware, because the numbers of the ethernet interfaces are bound to a specific MAC address (in the /etc/iftab table) by the ubuntu installer.
 
 
 
 
=== Windows DomU guest ===
 
In recent processors, Intel and AMD use an extension that gives xen the ability to run guest machines that are not aware of xen at all. The processor flag is called 'VMX' and is present in alle Core2 and some D9xx processors (called 'Vanderpool' or 'VT') as well as in AM2 processors ('called 'Pacifica').
 
With the help of qemu (a processor emulation project), xen is able to provide a complete boot process from bios. The necessary package is installed by <code><nowiki> apt-get install xen-ioemu-3.0 </nowiki></code> from universe repository.
 
Here is an example configuration (vmx-guest.cfg) using a bootable cdrom as iso-image under /usr/local/bootimage.iso and a loopback (see above) file /usr/local/diskimage-windows for the later harddisk image:
<pre><nowiki>
kernel = "/usr/lib/xen-ioemu-3.0/boot/hvmloader"
builder='hvm'
memory = 384
name = "vmx-guest"
vcpus=1
vif = [ 'bridge=xenbr0' ]
disk = ['file:/usr/local/diskimage-windows,ioemu:hda,w','file:/usr/local/bootimage.iso,hdc:cdrom,r']
device_model ='/usr/lib/xen-ioemu-3.0/bin/qemu-dm'
boot='d'
vnc=1
vncviewer=1
serial='pty'
ne2000=0
</nowiki></pre>
Note the new syntax for cdrom in xen 3.0.3!
 
<code><nowiki>boot='d'</nowiki></code> lets the guest boot from the cd image, after finishing installation, the next boot should be launched from disk using <code><nowiki>boot='c'</nowiki></code>
 
<code><nowiki>vnc=1</nowiki></code> allows us to connect to the guest after a launch using the vncviewer software:
<pre><nowiki>
xm create vmx-guest.cfg
vncviewer localhost
</nowiki></pre>
</nowiki></pre>
**** You can probably use /boot/vmlinuz-2.6-xen0, as it is symlinked in the right place


KynanCheng: May 6, 2006. Xen3.0 on Dapper Beta 2 works well using the manual install method. The only difference is that the current tarball uses one universal -xen kernel instead of the -xen0/U kernels.  In order to get the system to boot, you will have to create an initrd file and add one more line to the Xen grub stanza <code><nowiki>module /boot/initrd.img-xen-2.6 </nowiki></code> (NOTE: it's a module line not an initrd line)
See http://wiki.xensource.com/xenwiki/InstallationNotes?highlight=%28grub%29 and http://wiki.xensource.com/xenwiki/GettingStarted?highlight=%28initrd%29 for more information.


** In some versions of the tarball, the Xen folks packed it with weird UIDs. Make '''certain''' that before you execute the install script you chown everything to root, ie. "<code><nowiki>chown -R root: *</nowiki></code>" from the place you unpacked the install tarball.
* You may face problems running other distributions than Edgy as domU, in such cases download the original XENsource archive and use the kernel version out of this packages:
<pre><nowiki>
wget http://bits.xensource.com/oss-xen/release/3.0.4-1/bin.tgz/xen-3.0.4_1-install-x86_32p.tgz
tar zvfx xen-3.0.4_1-install-x86_32p.tgz
cd dist
sudo ./install.sh</nowiki></pre>
* If you need a ramdisk, remember to create one with mkinitramfs before:
<pre><nowiki>
sudo depmod -v 2.6.16.33-xen
cd /boot
sudo mkinitramfs -o /boot/initrd.img-2.6.16.33-xen 2.6.16.33-xen</nowiki></pre>
 
* You can find ready-to-go distributions at: [http://jailtime.org/]
* See also [http://help.ubuntu.com/community/XenOnUbuntuBinaryInstall] for a detailed HowTo.
 
== Known Bugs ==
 
* The edgy xen kernel is reported to crash if two DomUs are started, see: https://launchpad.net/distros/ubuntu/+source/xen-source-2.6.17/+bug/71348 (believed to be fixed with the feisty xen kernels)
 


JasonSmithThailand: I am working on a Xen-on-Breezy document in /XenOnUbuntuBreezy.
* You should disable hyperthreading in you BIOS else your Xen Kernel will reboot indefinitively.
----


I have packages mocked up right now, and they're nearly usable, although I have to fix the dependencies on them.  I'll upload them somewhere to my website soon


I have confirmed that Ubuntu Hoary still uses devfs for dev entries in their initrds, so if you the default Xen kernel configs don't work for you, you may want to use an initrd and be sure you compile devfs in.


----


From redjar Wed Mar 30 22:35:37 +0100 2005
==== Steps ====
From: redjar
 
Date: Wed, 30 Mar 2005 22:35:37 +0100
* apt-get install ssh bridge-utils gcc make patch binutils zlib1g-dev python-dev libncurses-dev x-dev libssl-dev
Subject: ubuntu/xen install howto
The packages x-dev and libssl-dev seem to be necessary for building the xen-tools.
Message-ID: <20050330223537+0100@https://www.ubuntulinux.org>
 
* apt-get install bin86 bcc libc6-dev-i386
so you can build the hvmloader as well.
 
Download source distribution, unpack, cd to xen-3.0.4_1-src and do
 
<pre><nowiki>
# make prep-kernels
# pico linux-2.6.16.33-xen/Makefile
Add -fno-stack-protector to CFLAGS in the makefile above (I added it to line 343) - thanks to Peter Fokkinga for the tip.
# make dist
</nowiki></pre>
Add cciss support to kernel in order for Xen to boot successfully on this HP box:
 
<pre><nowiki>
# make linux-2.6-xen-config CONFIGMODE=menuconfig
check "Device Drivers -> SCSI device support -> SCSI device support" - link statically.
check "Device Drivers -> SCSI device support -> SCSI disk support" - link statically.
check "Device Drivers -> SCSI device support -> SCSI generic support" - link statically.
check "Device Drivers -> Block devices - >Compaq Smart Array 5xxx support" - link statically.
# make linux-2.6-xen-build
# make install
</nowiki></pre>
Add this to /boot/grub/menu.lst


Came across this page:
<pre><nowiki>
http://cosi.clarkson.edu/knowledge/workshops/sp05/installingxen/xen-tutorial.html
title Xen 3.0.4 / XenLinux 2.6
kernel /boot/xen-3.0.gz console=vga
module /boot/vmlinuz-2.6-xen root=/dev/cciss/c0d0p1 ro console=tty0
savedefault
boot
</nowiki></pre>
and reboot.


I have tested it, it works fine, but the files names have changed.


----
Now, if you try to export an LVM partition as "sda1" it will fail with a boot log containing "xen_blk: can't get major 8 with name sd" followed by a guest kernel panic. This is a known problem described in the XenFaq and the solution is to  build a domU kernel w/o SCSI support. These are the steps to be done in directory xen-3.0.4_1-src/:


MartinManey: I'm starting out to try this on a fresh "server" install of Hoary.
<pre><nowiki>
Of the packages they list as needed, I found bridge-utils, gcc, python-twisted, and the libcurl2-* packages were not already installed.
# make linux-2.6-xenU-config CONFIGMODE=menuconfig
At least without universe there don't appear to be any lubcurl2 packages, so my first attempt will be with libcurl3.
UNcheck "Device Drivers -> SCSI device support -> SCSI device support" completely
''Probably didn't need libcurl-dev or gcc to use the install kit.
remember to edit ...xenU/Makefile to get a no-stack-protection compile.
Worked well as far as getting Xen0 running.
# make linux-2.6-xenU-build
Getting the (expected) tls warning, but no visible problems so far.
# cp linux-2.6.16.33-xenU/vmlinuz /boot/vmlinuz-2.6-xenU
Lost eth0 config; patched in by adding "auto eth0" in /etc/network/interfaces for now.''
</nowiki></pre>
Had to create directories /var/lib/xen/xend-db/domain and .../vnet by hand before xend would run.
I've since gotten a Fedora Core 3 image, built using the rpmstrap tool, to boot, but have been busy with other work since getting to that point.


----


JimKleckner: It would be good to have a brief discussion here (or if too big, a separate page) of whether it makes sense to eventually have Xen an option as part of a standard version of Ubuntu or not.  What are the barriers?


----
This config file then works for a Linux PV guest:


JasonSmithThailand: I would very much like it if Xen were a standard part of Ubuntu.  Virtualization is one of those things that you cannot live without, once you play with it.  I think if Xen were known to run on the majory of Linux systems, there would be good opportunities for new kinds of cool software or tools.  The reason I stopped halfway through documenting /XenOnUbuntuBreezy is becuase the kernel patches seemed mutually exclusive at the time, so it was not possible to augment an otherwise stock Ubuntu kernel with Xen.  The only solution is doing a lot of work but still having a (slightly) incompatible kernel (mostly removing some drivers, IIRC) as other Ubuntu users.
<pre><nowiki>
#  -*- mode: python; -*-


----
# Kernel image file.
kernel = "/boot/vmlinuz-2.6-xenU"
memory = 64
name = "debian1"
vif = [ '' ]
disk = [ 'phy:vm-disks/debian1,sda1,w', 'phy:vm-disks/debian1-swap,sda2,w' ]
root = "/dev/sda1 ro"
extra = "4"
</nowiki></pre>


chris.steelMontreal: Xen is really important and powerful. Para-virtualization totally rocks. Too bad I had to go back to a Hoary server in order to use it. The Ubuntu xen3 install page had some good clues but that mountain was too high! Perhaps a few 'history > xen3onbreezy.txt' links and a good Ubuntu kernel patch doc and the edited .h files might have got me through but my head was spinning and I caved. Hopefully Dapper will have a nice xen3 kernel selection and an initrd with at least LVM support and the other basic I/O etc.  Any more breadcrumbs would be helpful ; )
and  


JackWasey: Xen 3.0 merged with unstable debian: http://www.debian-administration.org/articles/396


---
Cartel: I have had success with Xen 3.0.2 under Dapper and have published unnofficial packages for it. See here: https://wiki.ubuntu.com/XenVirtualMachine/XenOnUbuntuDapper. Basically everything works except some uncommon hardware.





2007年11月21日 (三) 17:20的版本

{{#ifexist: :XenVirtualMachine/zh | | {{#ifexist: XenVirtualMachine/zh | | {{#ifeq: {{#titleparts:XenVirtualMachine|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:XenVirtualMachine|1|-1|}} | zh | | }}

This page is mostly old junk, and the useful parts are being migrated to Xen.



Using loopback-mounted-file

  • Generate loopback file as sparse file (not written entirely to disk but filled on demand) (replace 'edgy.ext3' with whatever name you want for it, ie. 'system1.ext3':
sudo dd if=/dev/zero of=/usr/local/edgy.ext3 bs=1024k seek=4096 count=0 
  • Create filesystem within (replace 'edgy.ext3' with what the name you used in step 1):
sudo mkfs.ext3 /usr/local/edgy.ext3 

Mkfs will tell you that this is no block device. Since you already know that (do you?) you can tell it to create the filesystem nevertheless. (so say Yes)

  • Loopback mount filesystem (replace 'edgy' and 'edgy.ext3' with the name you used in step 1):
sudo mkdir /mnt/edgy
sudo mount /usr/local/edgy.ext3 /mnt/edgy -o loop 


  • Install edgy base into it (replace 'edgy' with the release-name (version) of ubuntu you want (dapper, edgy, feisty, etc), replace '/mnt/edgy' with the name you used in step 1):

32bit Host O/S & 32bit virtual host sudo debootstrap edgy /mnt/edgy

64bit Host O/S & 64bit virtual host sudo debootstrap --arch amd64 edgy /mnt/edgy

  • Give it the kernel modules (the module name depends on whether you use the desktop or server edition) (this implies you are installing the same release of ubuntu as you are currently running on the system as the host O/S, which is edgy throughout this example) (replace '/mnt/edgy' with what you used in step 1):

32bit Host OS & 32bit Virtual host: sudo cp -a /lib/modules/2.6.19-4-generic/ /mnt/edgy/lib/modules/

64bit Host OS & 64bit Virtual host: sudo cp -a /lib/modules/2.6.19-4-generic-amd64/ /mnt/edgy/lib/modules/

  • Change whatever you want to be changed before the first boot. Examples:

The network example below is somewhat confusing. Basically, whatever your Host O/S's (pre-existing) IP address is, put that in for the gateway, and make sure that the 'netmask' and 'address' put the virtual host into the same broadcast group as the host o/s (simpler example: address: 192.168.1.222 netmask: 255.255.255.0 gateway: 192.168.1.111, the 222 is the virtual host, the 111 is the host o/s's actual IP).

If you followed the directions above regarding the network configuration you can run the following command:

sudo nano /etc/network/interfaces

and enter the following information

cat /mnt/edgy/etc/network/interfaces 
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp 

otherwise do the following:

cat /mnt/edgy/etc/network/interfaces 
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.44.247
netmask 255.255.252.0
gateway 192.168.47.254 

Then configure the rest of the files:

cat /mnt/edgy/etc/hosts
127.0.0.1       localhost
127.0.1.1       edgyvm 
cat /mnt/edgy/etc/hostname 
edgyvm 
cat /mnt/edgy/etc/fstab
proc            /proc           proc    defaults        0       0
/dev/hda1       /               ext3    defaults,errors=remount-ro 0       1
  • Umount the loopback partition
 
sudo umount /mnt/edgy 
  • Configure the guest, create /etc/xen/edgy-guest.cfg
kernel = "/boot/vmlinuz-2.6.19-4-generic"
ramdisk = "/boot/initrd.img-2.6.19-4-generic"
builder='linux'
memory = 128
name = "edgy-guest"
vcpus = 1
vif = [ 'bridge=xenbr0' ]
disk = [ 'file:/usr/local/edgy.ext3,ioemu:hda1,w' ]
root = "/dev/hda1 ro"

Note: Change hda1 by sda1 if you are using some SATA or SCSI Controller

Note that root points to the virtual root partition of the domU and not of dom0. It is recommended to give each domU a swap partition, in such case your cfg-file may look as follows (don't forget to add it to the /etc/fstab of the virtual host, so it mounts it on boot-up):

disk = [ 'file:/usr/local/edgy.ext3,ioemu:hda1,w','phy:/dev/hda6,ioemu:hda2,w']
  • Now you can create your xen domain
 
sudo xm create edgy-guest.cfg 
  • You can connect to the guest using the command below or any network based access that you install later on (openssh-server, vncserver, remote-X11, ...)
 
sudo xm console edgy-guest 

Use crtl + ] to get out of console.

If you logged in via putty use ctrl + 5 to leave the domu-console.


Hypervisor and dom0

The host for virtualized machines and the priviledged first guest

  • The Xen kernel packages currently do not create an initrd image when they are installed. (This will probably be changed in the future). To create an initrd image run the following command:
sudo mkinitramfs -o /boot/xen0-linux-2.6.17-6-generic-xen0.initrd.img 2.6.17-6-generic-xen0

Respectively:

sudo mkinitramfs -o /boot/xen0-linux-2.6.17-6-server-xen0.initrd.img 2.6.17-6-server-xen0

if you are using the Ubuntu server distribution.


  • Now that the kernel and initrd is installed, you have to setup grub. Add the following to your /boot/grub/menu.lst:
title XEN/2.6.17
root (hd0,0)
kernel /boot/xen-3.0-i386-pae.gz
module /boot/xen0-linux-2.6.17-6-generic-xen0 root=/dev/xxx ro
module /boot/xen0-linux-2.6.17-6-generic-xen0.initrd.img

where xxx is the partition where your root is located. Edgy can use a new way of identifying you partitions by UUID. In this case, just use that syntax for root e.g. root=UUID=f5cf5b9a-ed1a-4d6a-a707-a606574e2b6f. You can obtain the UUIDs of your partitions using the command blkid (found in /sbin). If you are using the server edition, please make sure you select the right terms in the module lines (xen0-linux-2.6.17-6-server-xen0...). Note: On amd64, use xen-3.0-amd64.gz instead of xen-3.0-i386.gz

Note: kernel and modules may need to have the /boot removed from them to get this to work. ie

kernel /xen-3.0-i386.gz


domU

The guest machines running under the xen hypervisor

Xen-tools can set up Ubuntu, Debian, CentOS systems, and also any other system if you give it a proper tarball.

A domU guest system can be built using the same kernel image that was used for dom0.

  • Decide whether to use a loopback-mounted file or a raw partition for a clients filesystem.

use loopback-mounted-file

  • In case of loopback, proceed like:
      • Generate loopback file as sparse file (not written entirely to disk but filled on demand:
sudo dd if=/dev/zero of=/usr/local/diskimage-guest.ext3 bs=1024k seek=4096 count=0 
      • Create filesystem within:
 
sudo mkfs.ext3 /usr/local/diskimage-guest.ext3 

Mkfs will tell you that this is no block device. Since you already know that (do you?) you can tell it to create the filesystem nevertheless.

      • Loopback mount filesystem:
 
sudo mount /usr/local/diskimage-guest.ext3 /mnt -o loop 
      • Install debootstrap:
sudo apt-get install debootstrap 
      • Install edgy base into it:
 
sudo debootstrap edgy /mnt 
      • Give it the kernel modules (the module name depends on whether you use the desktop or server edition)
 
sudo cp -a /lib/modules/2.6.17-6-generic-xen0/ /mnt/lib/modules 
      • Change whatever you want to be changed before the first boot (/mnt/etc/apt/sources.list, /mnt/etc/network/interfaces, /mnt/etc/hostname, /mnt/etc/hosts)
      • Unmount
 
sudo umount /mnt 
      • Configure the guest, create /etc/xen/edgy-guest.cfg
kernel = "/boot/xen0-linux-2.6.17-6-generic-xen0"
ramdisk = "/boot/xen0-linux-2.6.17-6-generic-xen0.initrd.img"
builder='linux'
memory = 128
name = "edgy-guest"
vcpus = 1
vif = [ 'bridge=xenbr0' ]
disk = [ 'file:/usr/local/diskimage-guest.ext3,ioemu:hda1,w' ]
root = "/dev/hda1 ro"

Note that root points to the virtual root partition of the domU and not of dom0. It is recommended to give each domU a swap partition, in such case your cfg-file may look as follows:

disk = [ 'file:/usr/local/diskimage-guest.ext3,ioemu:hda1,w','phy:/dev/hda6,ioemu:hda2,w']
  • Give it a try
  • First start xend if it is not already started:
xend start 
  • Now you can create your xen domain
 
sudo xm create edgy-guest.cfg 
  • You can connect to the guest using
 
sudo xm console edgy-guest 

or any network based access that you install later on (ssh or vnc or remote-X11)


use raw partition

  • In case of a raw partition you want to use we need to create a file-system on it first.
      • If e.g /dev/hda6 is our raw unformated partiton create a ext3-filesystem:
 
mkfs -t ext3 /dev/hda6 
      • The next step is to create a mountpoint and to mount it:
 
sudo mkdir /media/hda6 && sudo mount /dev/hda6 /media/hda6 
      • All what follows now is almost identical to "use loopback-mounted-file"
      • Install edgy base into it:
 
sudo debootstrap edgy /media/hda6 
      • Give it the kernel modules:
 
sudo cp -a /lib/modules/2.6.17-6-generic-xen0/ /media/hda6/lib/modules 
      • Change whatever you want to be changed before the first boot (/media/hda6/etc/apt/sources.list, /media/hda6/etc/network/interfaces, /media/hda6/etc/hostname, /media/hda6/etc/hosts)
      • Unmount
 
sudo umount /media/hda6 
      • Configure the guest, create /etc/xen/edgy-guest.cfg
kernel = "/boot/xen0-linux-2.6.17-6-generic-xen0"
ramdisk = "/boot/xen0-linux-2.6.17-6-generic-xen0.initrd.img"
builder='linux'
memory = 128
name = "edgy-guest"
vcpus = 1
vif = [ 'bridge=xenbr0' ]
disk = [ 'phy:/dev/hdX,hda1,w' ]
root = "/dev/hda1 ro"

Note that root points to the virtual root partition of the domU and not of dom0. It is recommended to give each domU a swap partition, in such case your cfg-file may look as follows:

disk = [ 'phy:/dev/hdXX,hda1,w','phy:/dev/hdXY,hda2,w']
  • Give it a try
  • First start xend if it is not already started:
xend start 
  • Now you can create your xen domain
 
sudo xm create edgy-guest.cfg 
  • You can connect to the guest using
 
sudo xm console edgy-guest 

or any network based access that you install later on (ssh or vnc or remote-X11)

Especially if you want to set up a larger number of virtual machines, it's strongly recommended to set up LVM and use logical volumes for your virtual machines.




Installing DomU w/ debootstrap

First, setup and configure lvm, create an ext3 and swap partition in lvm, and mount your lvm partition to /xen.

apt-get install debootstrap

I prefer to install from CD, as it's faster. Mount your CD-Rom to /media/cdrom, and mount your future domU root partition to /xen

debootstrap dapper /xen file:/media/cdrom

You should see lots of I: messages, and finally the prompt. Change directories to the root directory of your new filesystem.

Xen configuration options

Using your favorite editor (back in Dom0), create /etc/xen/dom1.cfg with the following text

kernel = "/boot/vmlinuz-2.6-xen"
memory = 128
name = "dom1"
vif = [ '' ]
dhcp = "dhcp"
disk = ['phy:/dev/xen_lvm/dom1,hda1,w','phy:/dev/xen_lvm/dom1_swap,hdb1,w']
root = "/dev/hda1 ro"
extra = "4"

Create a DomU

xm create dom1.cfg -c

Login with root, no password (you want to change that!)

Changes Necessary on the DomU's Filesystem

mv ./lib/tls ./lib/tls.disabled

in ./etc/network/interfaces (change the relevant numbers)

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.3.101
netmask 255.255.255.0
network 192.168.3.0
broadcast 192.168.3.255
gateway 192.168.3.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 1.2.3.4 1.2.3.5


Copy the Dom0's sources list: cp /etc/apt/sources.list ./etc/apt/sources.list and edit them if you wish.


In ./etc/fstab

# /fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hda1       /               ext3    defaults,errors=remount-ro 0       1
/dev/hdb1       none            swap    sw              0       0

umount /dev/xen_lvm/dom1 (we don't want two operating systems writing to the same partition!)

Locale setup:

The locale isn't set up properly by default. Resolve this by:

Install base packages for your language:
apt-get install language-pack-en-base

Install/Reconfigure localeconf via either:
apt-get install localeconf
dpkg-reconfigure localeconf

*** Manage locale configuration files with debconf? -> yes
*** Please select the default system locale. -> Your locale. Mine is en_US ISO-8859-1 for example.
*** Select the environment settings that should override the default locale.  -> Select All
*** In the following dialogs always select what you set for your locale above.

Install/reconfigure locales:
apt-get install locales
dpkg-reconfigure locales

*** Here, use the same locale you used in the localeconf setup.

Setting up your hostname

Manually edit /etc/hostname with your domU hostname.
Manually edit /etc/hosts (If you used debootstrap, you need to set this file up from scratch.)
(set the 127.0.0.1 host in /etc/hosts to sync with the host in /etc/hostname)

At this point you want to set up sshd, so you can log into your new virtual machine remotely! You are ready!

lib tls error

This should only be on older versions of Ubuntu, or on domU guests maybe?

If you receive a large warning message during boot-up about /lib/tls, you may do one of the following:

  • mv /lib/tls /lib/tls.disabled (easy, but the issue may crop up again after an upgrade)
  • Divert Xen using a Script (This makes sure upgrades don't put /lib/tls back again.
  • Build your own glibc (Instructions from XenSource's Wiki)

Note: Disabling /lib/tls gives significantly poor performance for glibc. Find a way to install a Xen-friendly glibc. Removing /lib/tls is disabling the thread-local storage (tls) handling features of glibc by hiding them.

libcrypto error

Probably only on older versions of Ubuntu.

If when starting xend, you get the error: blktapctrl: error while loading shared libraries: libcrypto.so.0.9.7: cannot open shared object file: No such file or directory Figure out the version of libcrypto you have:

ls /usr/lib/libcrypto.so.*

for example :

/usr/lib/libcrypto.so.0.9.8

Make a symbolic link to it:

ln -s /usr/lib/libcrypto.so.0.9.8 /usr/lib/libcrypto.so.0.9.7

ethx missing

When porting a physical system to a xen image file, eth0 was missing. Xen assigned eth2 as the first network interface. To correct this issue comment out eth0 in /etc/iftab. In fact this also happens if you move an installation to another hardware, because the numbers of the ethernet interfaces are bound to a specific MAC address (in the /etc/iftab table) by the ubuntu installer.



Windows DomU guest

In recent processors, Intel and AMD use an extension that gives xen the ability to run guest machines that are not aware of xen at all. The processor flag is called 'VMX' and is present in alle Core2 and some D9xx processors (called 'Vanderpool' or 'VT') as well as in AM2 processors ('called 'Pacifica').

With the help of qemu (a processor emulation project), xen is able to provide a complete boot process from bios. The necessary package is installed by apt-get install xen-ioemu-3.0 from universe repository.

Here is an example configuration (vmx-guest.cfg) using a bootable cdrom as iso-image under /usr/local/bootimage.iso and a loopback (see above) file /usr/local/diskimage-windows for the later harddisk image:

kernel = "/usr/lib/xen-ioemu-3.0/boot/hvmloader"
builder='hvm'
memory = 384
name = "vmx-guest"
vcpus=1
vif = [ 'bridge=xenbr0' ]
disk = ['file:/usr/local/diskimage-windows,ioemu:hda,w','file:/usr/local/bootimage.iso,hdc:cdrom,r']
device_model ='/usr/lib/xen-ioemu-3.0/bin/qemu-dm'
boot='d'
vnc=1
vncviewer=1
serial='pty'
ne2000=0

Note the new syntax for cdrom in xen 3.0.3!

boot='d' lets the guest boot from the cd image, after finishing installation, the next boot should be launched from disk using boot='c'

vnc=1 allows us to connect to the guest after a launch using the vncviewer software:

xm create vmx-guest.cfg
vncviewer localhost


  • You may face problems running other distributions than Edgy as domU, in such cases download the original XENsource archive and use the kernel version out of this packages:
wget http://bits.xensource.com/oss-xen/release/3.0.4-1/bin.tgz/xen-3.0.4_1-install-x86_32p.tgz
tar zvfx xen-3.0.4_1-install-x86_32p.tgz
cd dist
sudo ./install.sh
  • If you need a ramdisk, remember to create one with mkinitramfs before:
sudo depmod -v 2.6.16.33-xen
cd /boot
sudo mkinitramfs -o /boot/initrd.img-2.6.16.33-xen 2.6.16.33-xen
  • You can find ready-to-go distributions at: [1]
  • See also [2] for a detailed HowTo.

Known Bugs


  • You should disable hyperthreading in you BIOS else your Xen Kernel will reboot indefinitively.



Steps

  • apt-get install ssh bridge-utils gcc make patch binutils zlib1g-dev python-dev libncurses-dev x-dev libssl-dev

The packages x-dev and libssl-dev seem to be necessary for building the xen-tools.

  • apt-get install bin86 bcc libc6-dev-i386

so you can build the hvmloader as well.

Download source distribution, unpack, cd to xen-3.0.4_1-src and do

# make prep-kernels
# pico linux-2.6.16.33-xen/Makefile
Add -fno-stack-protector to CFLAGS in the makefile above (I added it to line 343) - thanks to Peter Fokkinga for the tip.
# make dist

Add cciss support to kernel in order for Xen to boot successfully on this HP box:

# make linux-2.6-xen-config CONFIGMODE=menuconfig
check "Device Drivers -> SCSI device support -> SCSI device support" - link statically.
check "Device Drivers -> SCSI device support -> SCSI disk support" - link statically.
check "Device Drivers -> SCSI device support -> SCSI generic support" - link statically.
check "Device Drivers -> Block devices - >Compaq Smart Array 5xxx support" - link statically.
# make linux-2.6-xen-build
# make install

Add this to /boot/grub/menu.lst

title Xen 3.0.4 / XenLinux 2.6
kernel /boot/xen-3.0.gz console=vga
module /boot/vmlinuz-2.6-xen root=/dev/cciss/c0d0p1 ro console=tty0
savedefault
boot

and reboot.


Now, if you try to export an LVM partition as "sda1" it will fail with a boot log containing "xen_blk: can't get major 8 with name sd" followed by a guest kernel panic. This is a known problem described in the XenFaq and the solution is to build a domU kernel w/o SCSI support. These are the steps to be done in directory xen-3.0.4_1-src/:

# make linux-2.6-xenU-config CONFIGMODE=menuconfig
UNcheck "Device Drivers -> SCSI device support -> SCSI device support" completely
remember to edit ...xenU/Makefile to get a no-stack-protection compile.
# make linux-2.6-xenU-build
# cp linux-2.6.16.33-xenU/vmlinuz /boot/vmlinuz-2.6-xenU


This config file then works for a Linux PV guest:

#  -*- mode: python; -*-

# Kernel image file.
kernel = "/boot/vmlinuz-2.6-xenU"
memory = 64
name = "debian1"
vif = [ '' ]
disk = [ 'phy:vm-disks/debian1,sda1,w', 'phy:vm-disks/debian1-swap,sda2,w' ]
root = "/dev/sda1 ro"
extra = "4"

and