个人工具

“UbuntuHelp:XenVirtualMachine/XenOnUbuntuEdgy”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{From|https://help.ubuntu.com/community/XenVirtualMachine/XenOnUbuntuEdgy}} {{Languages|UbuntuHelp:XenVirtualMachine/XenOnUbuntuEdgy}} == Hypervisor and dom0 == '''The host for virtualiz...)
 
(正在将页面替换为 '{{From|https://help.ubuntu.com/community/XenVirtualMachine/XenOnUbuntuEdgy}} {{Languages|UbuntuHelp:XenVirtualMachine/XenOnUbuntuEdgy}} This info has been merged into the ...')
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/XenVirtualMachine/XenOnUbuntuEdgy}}
 
{{From|https://help.ubuntu.com/community/XenVirtualMachine/XenOnUbuntuEdgy}}
 
{{Languages|UbuntuHelp:XenVirtualMachine/XenOnUbuntuEdgy}}
 
{{Languages|UbuntuHelp:XenVirtualMachine/XenOnUbuntuEdgy}}
== Hypervisor and dom0 ==
+
This info has been merged into the main Xen wiki page at XenVirtualMachine
'''The host for virtualized machines and the priviledged first guest'''
+
 
+
In previous Ubuntu releases, using Xen required building and compiling from source. Starting with Edgy Eft (6.10), this is no longer necessary.  You can easily convert an existing running Ubuntu install (Edgy Eft or later) so that the Dom0 is your current setup, and you can follow on to create DomU instances as desired. These instructions are for converting your existing setup in this manner.
+
 
+
To install XEN on a machine running Edgy Eft or later, do the following:
+
 
+
* Make sure that you are running edgy and that you have universe enabled in your /etc/apt/sources.list
+
 
+
* Run the following command:
+
<pre><nowiki>
+
sudo apt-get install xen-hypervisor-3.0-i386 xen-image-xen0-2.6.17-6-generic-xen0 xen-utils-3.0 xen-ioemu-3.0
+
</nowiki></pre>. If you are running a server kernel, you must change this to
+
<pre><nowiki>
+
sudo apt-get install xen-hypervisor-3.0-i386-pae xen-image-xen0-2.6.17-6-server-xen0 xen-utils-3.0 xen-ioemu-3.0
+
</nowiki></pre> so that both the kernel and the hypervisor are PAE-enabled (if there is a mismatch you won't be able to boot).
+
 
+
Note: For amd64, use xen-hypervisor-3.0-amd64 instead of xen-hypervisor-3.0-i386
+
 
+
This will install the XEN hypervisor, the kernel used by the guest host and guest domains, and the userspace utilities used for working with Xen domains.
+
 
+
* 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.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>
+
 
+
* Now you will have to adjust the network settings that XEN will use. The xend daemon is configured in `/etc/xen/xend-config.sxp`. Add the following line to `xend-config.sxp`:
+
<pre><nowiki>
+
(network-script network-bridge)
+
</nowiki></pre>
+
 
+
* If you are going to use the network-bridge, you must have the bridge-utils package installed (else your bridge won't be created by the network-bridge script and you will get an error like 'Error: Device 0 (vif) could not be connected. Hotplug scripts not working.' when attempting to start your DomU). To install it, run the following command:
+
<pre><nowiki>
+
sudo apt-get install bridge-utils
+
</nowiki></pre> The later domU examples assume that you use a bridged networking using device xenbr0. ''If installing bridge-utils doesn't fix this, try moving the file /etc/udev/xen-backend.rules to /etc/udev/rules.d/10-xen-backend.rules''
+
 
+
 
+
* Now you should be able to reboot your machine to have XEN activated at the next time you boot the kernel. If you want to enable the NVidia drivers on your xen kernel, see [[UbuntuHelp:XenVirtualMachine/NVidiaOnXenOnUbuntuEdgy]]
+
 
+
== domU ==
+
''' The guest machines running under the xen hypervisor'''
+
 
+
This chapter describes how to set up the virtual machines. You can do this by hand, but it's also possible to let xen-create-image do the hard work. It automaticaly creates the filesystem, installation and configuration files (both inside and outside the VM). See http://www.xen-tools.org/ or just install it using apt:
+
<pre><nowiki>
+
sudo apt-get install xen-tools
+
</nowiki></pre>
+
 
+
Xen-tools can set up Ubuntu, Debian, CentOS systems, and also any other system if you give it a proper tarball.
+
 
+
=== Edgy ===
+
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.
+
 
+
=== Others using VMX and qemu ===
+
 
+
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>
+
 
+
=== Installing other distributions as DomU ===
+
 
+
* 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)
+
 
+
* 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.
+
 
+
* You should disable hyperthreading in you BIOS else your Xen Kernel will reboot indefinitively.
+
 
+
== Resources ==
+
 
+
[http://www.xensource.com] - XenSource
+
 
+
[[category:CategoryDocumentation]]
+
 
+
== Related Documentation ==
+
* How to use more than 3 virtual interfaces in the DomU's. See : http://www.dalouche.com/wordpress/2006/11/26/howto-use-more-than-3-virtual-interfaces-with-xen-by-using-ip-aliasing/
+
 
+
* Xen User Guide. See: http://www.cl.cam.ac.uk/research/srg/netos/xen/readmes/user/user.html
+
* See http://help.ubuntu.com/community/XenOnUbuntuBinaryInstall for a detailed introduction on how to install the Xen 3.0 binaries.
+
* Windows XP and Xen. See: http://lists.xensource.com/archives/html/xen-users/2006-06/msg00599.html
+
* Feisty users: XenVirtualMachine/XenOnUbuntuFeisty
+
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

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

This info has been merged into the main Xen wiki page at XenVirtualMachine