차례
- Xen Overview
- Compatibility
- Installation on lenny
- Dom0 (host)
- DomU (guest)
- Additional note for domU on lenny using xen-tools
- Installation on etch
- Dom0 (host)
- DomU (guests)
- Xen on Unstable/Sid
- Using Debian-Installer
- Package maintenance
- Common Errors
- dom0 automatic reboots
- Error "Device ... (vif) could not be connected"
- error: CDROM boot failure
- 4gb seg fixup errors
- No login prompt when using `xm console`
- 'clocksource/0: Time went backwards'
- "Error: Bootloader isn't executable"
- "ERROR (XendCheckpoint:144) Save failed on domain mydomu32 (X)."
- PV drivers on HVM guest
- Resources
Xen Overview
Modern computers are sufficiently powerful to use virtualization to present the illusion of many smaller virtual machines (VMs), each running a separate operating system instance. Successful partitioning of a machine to support the concurrent execution of multiple operating systems poses several challenges. Firstly, virtual machines must be isolated from one another: it is not acceptable for the execution of one to adversely affect the performance of another. This is particularly true when virtual machines are owned by mutually untrusting users. Secondly, it is necessary to support a variety of different operating systems to accommodate the heterogeneity of popular applications. Thirdly, the performance overhead introduced by virtualization should be small.
Xen is a virtual machine monitor for x86 that supports execution of multiple guest operating systems with unprecedented levels of performance and resource isolation. Xen is Open Source software, released under the terms of the GNU General Public License. We have a fully functional ports of Linux 2.6 running over Xen, and regularly use it for running demanding applications like MySQL, Apache and PostgreSQL. Any Linux distribution (RedHat, SuSE, Debian, Mandrake) should run unmodified over the ported OS.
In addition to Linux, members of Xen's user community have contributed or are working on ports to other operating systems such as NetBSD (Christian Limpach), FreeBSD (Kip Macy) and Plan 9 (Ron Minnich).
It is also possible to run some other, not ported, operating systems if your CPU has hardware virtualization support (VT or Pacifica).
Compatibility
- dom0 works on kernels 2.6.18 from Etch and 2.6.26 from Lenny, but not with kernel 2.6.24 from Etch-n-half;
- domU should work with all kernels (2.6.18 and 2.6.24 from Etch and 2.6.26 from Lenny);
- a Lenny dom0 on amd64 can run any domU (Etch or Lenny, i386 or amd64);
- a Lenny dom0 on i386 can, or should be able to, run any 32-bit domU (Etch or Lenny).
-
an Etch dom0 (2.6.18-*-xen) can only run 32-bit domU when it's i386 itself, a 64-bit Etch dom0 (using the amd64 kernel) can run a 64-bits domU and also a 32-bit domU, but only when using the amd64-kernel and a 32-bit userland!
Installation on lenny
Dom0 (host)
Quite the same way as Etch. The kernel is 2.6.26, the -xen variant contains patches from SuSE for dom0 support.
The xen-linux-system packages of interest are (Install the correct one for your architecture):
Serial console access
To get output from grub, XEN, the kernel and getty (login prompt) via both vga and serial console to work, here's an example of the right settings when using Lenny kernels and Xen 3.2:
In /boot/grub/menu.lst:
serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1
terminal --timeout=5 serial console
[...]
title Xen 3.2-1-amd64 / Debian GNU/Linux, kernel 2.6.26-2-xen-amd64
root (hd0,0)
kernel /boot/xen-3.2-1-amd64.gz com1=9600,8n1 console=com1,vga
module /boot/vmlinuz-2.6.26-2-xen-amd64 root=/dev/md0 ro console=tty0 console=hvc0
module /boot/initrd.img-2.6.26-2-xen-amd64
In contrast to the Etch configuration, there's no ttyS0 in the vmlinuz line!
In /etc/inittab you need at least these lines:
1:2345:respawn:/sbin/getty 38400 hvc0
2:23:respawn:/sbin/getty 38400 tty1
# NO getty on ttyS0!
The tty1 will show up at the vga output, and the hvc0 will show up at the serial console.
DomU (guest)
The Lenny Debian Installer fully supports installation of 32 bit guests under Xen using the netboot/xen variant. Images are available on any Debian mirror in the installer directory and contain a kernel, installer ramdisk and an example Xen configuration file. To install, fetch the xm-debian.cfg configuration file, edit to suit your tastes, and start the guest with the install=true option plus an optional (but strongly recommended) install-mirror=ftp://ftp.XX.debian.org/debian.
xm create -c xm-debian.cfg install=true install-mirror=ftp://ftp.XX.debian.org/debian
Newer images are also available from the daily builds. After grabbing the xm-debian.cfg configuration file and editing it to suit your tastes, start the guest with an additional install-installer=http://people.debian.org/~joeyh/d-i/images/daily/ to manually direct it to the daily builds:
WARNING, if you do not change the hard disks option on xm-debian.cfg this WILL overwrite your dom0 instead of installing to your domU. YOUR MACHINE WILL BE DESTROYED.
xm create -c xm-debian.cfg install=true \
install-mirror=ftp://ftp.XX.debian.org/debian \
install-installer=http://people.debian.org/~joeyh/d-i/images/daily/
See the comments in the configuration file for additional installation options.
Another way of creating a lenny domu is the following:
xen-create-image --hostname=vanila --size=8Gb --dist=lenny --memory=512M --ide --dhcp
Please note that the --dir option may be required, and it specified the directory where it will store your disk images. If you wish to specify a fixed ip address, use the --ip xxx.xxx.xxx.xxx instead of --dhcp option.
Once the guest is installed simply boot it using:
xm create -c xm-debian.cfg
Lenny only includes 32 bit (PAE) kernel support which means there is no installer support for 64 bit guests. You can continue to use the Etch kernels or obtain a newer upstream kernel which supports 64 bit operation (2.6.27+).
In addition to installing via Debian Installer xen-tools can also create a Lenny domU as described in the Etch section above.
The default Lenny kernel is the newer paravirt_ops version (2.6.26), which does not function as a dom0 (except for the -xen variants, which have dom0 support but also some issues running as domU (please clarify?). It will also not support PCI passthrough in a domU. For PCI passthrough, you have to run the 2.6.18 etch kernel as both dom0 and domU.
In Lenny the distinction between the Xen and non-Xen flavours of the kernel (with respect to domU support) is no longer present. The Debian Installer will install the -686-bigmem flavour.
xen-tools don't use hvc0 as the console device in /etc/inittab and don't install udev (leading to /dev/pts missing in domU).
This makes logging in via xm console and via ssh impossible, because getty doesn't have a proper console to attach to and ssh can't attach to a pseudo terminal.
To fix this,
1. add to /etc/xen-tools/xen-tools.conf:
serial_device = hvc0
2. and make domU with:
xen-create-image --hostname HOSTNAME (more options...) --role udev
Installation on etch
Upstream documentation can be found in the xen-docs-3.0 package (in /usr/share/doc/xen-docs-3.0/user.pdf.gz). It's also available online.
Dom0 (host)
-
Choose and install a xen-linux-system-KERNELVERSION package. This installs the kernel, a hypervisor and matching utilities.
-
On i386, install libc6-xen. This means that you don't have to delete /lib/tls or move it out of the way, as suggested by most Xen guides.
- Use Grub as bootloader (since Lilo and Xen don't play well with one another)
- You probably want to configure /etc/xen/xend-config.sxp (especially the network-script scheme).
The xen-linux-system packages of interest are (Install the correct one for your architecture):
If you need to apply some modifications to the kernel with the xen patch, then one way to do it is described DebianKernelCustomCompilation.
Serial console access
To get output from grub, XEN, the kernel and getty (login prompt) via both vga and serial console to work, here's an example of the right settings when using etch kernels and Xen 3.0.3:
In /boot/grub/menu.lst:
serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1
terminal --timeout=5 serial console
[...]
title Xen 3.0.3-1-i386-pae / Debian GNU/Linux, kernel 2.6.18-6-xen-686
root (hd0,0)
kernel /boot/xen-3.0.3-1-i386-pae.gz com1=9600,8n1 console=com1,vga
module /boot/vmlinuz-2.6.18-6-xen-686 root=/dev/md0 ro console=tty0 console=ttyS0,9600n8
module /boot/initrd.img-2.6.18-6-xen-686
In /etc/inittab you need at least these lines:
1:2345:respawn:/sbin/getty 38400 tty1
T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
DomU (guests)
The easiest way to create a domU is to use xen-tools (and, if this doesn't do what you need, Steve Kemp is keen and fast in implementing useful suggestions).
If you do not wish to use xen-tools, you could use this alternative guide, to setup the system using debootstrap.
Xen boots domUs using kernels stored on dom0, so you only need to install the corresponding linux-modules package in the domU. Alternatively, you can use PyGrub to boot kernels on the domU filesystem.
On i386, make sure you install libc6-xen.
If you install lenny domU on etch dom0, make sure you read this entry on XenFaq when you see messages on the console like 4gb seg fixup, process klogd (pid 2075), cs:ip 73:b7e25870. After applying the echo 'hwcap 0 nosegneg' > /etc/ld.so.conf.d/libc6-xen.conf && ldconfig, in the dom0 system, reboot, or, if you don't like rebooting (which requires you to stop domU's), restart all processes mentioned in the log messages (e.g. /etc/init.d/ssh restart, init q, etc..)
Xen on Unstable/Sid
There are three options:
Using Debian-Installer
The page DebianInstaller/Xen contains instructions on how to install Xen Dom0 and Etch DomU with DebianInstaller.See above for details of installing Lenny using Debian Installer.
Package maintenance
Debian's Xen packages are maintained by the pkg-xen project. (developpers' mailing list)
The Debian Developer's Package Overview page lists source packages that are maintained by the team.
Common Errors
dom0 automatic reboots
-
Note: if Xen is crashing and reboot automatically, you may want to use noreboot xen option, to prevent it from rebooting automatically. Grub example :
title Xen 3.1-1-i386 / Debian GNU/Linux, kernel 2.6.18-6-xen-686
root (hd0,0)
kernel /xen-3.1-1-i386.gz noreboot
module /vmlinuz-2.6.18-6-xen-686 root=/dev/foo ro console=tty0
module /initrd.img-2.6.18-6-xen-686
Error "Device ... (vif) could not be connected"
You need to configure some basic networking between dom0 and domU. Edit /etc/xen/xend-config.sxp
#(network-script network-dummy)
(network-script network-bridge)
for a basic bridge networking, and restart xend.
error: CDROM boot failure
You get the error :
That's because Xen can't boot from a cdrom iso image at the moment. i.e you can't have tap:aio:/path/to/mycd.iso,hdc:cdrom,r or file:/path/to/mycd.iso,hdc:cdrom,r.
Workaround: use losetup to create a loopback device for the cdrom ISO image, then use it in Xen configuration file. for example :
Now you can use /dev/loop9 in xen configuration file (/etc/xen/foobar.cfg) :
...
disk = [ 'phy:/dev/vg1/xpsp3,ioemu:hda,w', 'phy:/dev/loop/0,ioemu:hdc:cdrom,r' ]
...
then boot/install the guest OS.
note: yo should switch back to the tap:aio:/path/to/mycd.iso,hdc:cdrom,r syntax after installation, since loop back have to be recreated after you reboot the host system.
4gb seg fixup errors
Solution:
echo 'hwcap 0 nosegneg' > /etc/ld.so.conf.d/libc6-xen.conf && ldconfig
Read this XenFaq entry for more info.
No login prompt when using `xm console`
Using a lenny domU, make sure you have hvc0 listed in inittab, like 1:2345:respawn:/sbin/getty 38400 hvc0. There happened to be a lot of changes of default console unit used by Xen (tty1, xvc0, hvc0 etc) but for a Lenny domU (version > 2.6.26-9) it's hvc0.
'clocksource/0: Time went backwards'
If a domU crashes or freezes while uttering the famous lasts words 'clocksource/0: Time went backwards', your domU is likely using the xen clocksource instead of its own clock ticks. In practice, this seems to be the cause of infrequent lockups under load (and/or problems with suspending). A workaround is to decouple the clock in the domU from the dom0:
In your dom0 and domU /etc/sysctl.conf add the line: xen.independent_wallclock=1. On the dom0, edit the configuration file of the domU (e.g. /etc/xen/foobar.cfg and add (or expand) the extra-line: extra="clocksource=jiffies".
These settings can be activated without rebooting the domU. After editing the configuration files, issue sysctl -p and echo "jiffies"> /sys/devices/system/clocksource/clocksource0/current_clocksource on the domU prompt.
Because the clock won't be relying on the dom0 clock anymore, you probably need to use ntp on the domU to synchronize it properly to the world.
"Error: Bootloader isn't executable"
The above, rather cryptic, error (when starting a domU using xen-utils/xm create) is due to xen-utils not being able to find PyGrub. Modify your xm-debian.cfg config file to use the absolute directory (ie. bootloader="/usr/lib/xen-3.2-1/bin/pygrub" instead of bootloader="pygrub") and your domU should boot up fine.
"ERROR (XendCheckpoint:144) Save failed on domain mydomu32 (X)."
xm save/migration of a 32-Bit domU on a 64-Bit dom0 fails. It seems this is not supported with linux-image-2.6.26-2-xen-amd64 (http://readlist.com/lists/lists.xensource.com/xen-users/4/24225.html). One workaround is to use a 64-Bit Hypervisor with a 32-Bit dom0 (http://lists.xensource.com/archives/html/xen-users/2008-12/msg00404.html). See also 526695
PV drivers on HVM guest
It may be possible to build the PV drivers for use on HVM guests. These drivers are called unmodified_drivers and are part of the xen-unstable.hg repository. You can fetch the repository using mercurial thus:
The drivers reside under xen-unstable.hg/unmodified_drivers/linux-2.6. The README in this directory gives compilation instructions.
Resources
-
Homepage :http://www.xen.org
-
(quite basic and low-level) Upstream Documentation is on package xen-docs-3.0 package (in /usr/share/doc/xen-docs-3.0/user.pdf.gz). It's also available online.
- Xen Wiki :
-
German Wiki on Xen: http://www.xen-info.de/wiki
- Additional information required:
- Compiling a custom Xen DomU kernel. (e.g. adding tun device)