特殊:Badtitle/NS100:XenVirtualMachine
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/XenVirtualMachine }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/af | • {{#if: UbuntuHelp:XenVirtualMachine|Afrikaans| [[::XenVirtualMachine/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/ar | • {{#if: UbuntuHelp:XenVirtualMachine|العربية| [[::XenVirtualMachine/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/az | • {{#if: UbuntuHelp:XenVirtualMachine|azərbaycanca| [[::XenVirtualMachine/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/bcc | • {{#if: UbuntuHelp:XenVirtualMachine|جهلسری بلوچی| [[::XenVirtualMachine/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/bg | • {{#if: UbuntuHelp:XenVirtualMachine|български| [[::XenVirtualMachine/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/br | • {{#if: UbuntuHelp:XenVirtualMachine|brezhoneg| [[::XenVirtualMachine/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/ca | • {{#if: UbuntuHelp:XenVirtualMachine|català| [[::XenVirtualMachine/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/cs | • {{#if: UbuntuHelp:XenVirtualMachine|čeština| [[::XenVirtualMachine/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/de | • {{#if: UbuntuHelp:XenVirtualMachine|Deutsch| [[::XenVirtualMachine/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/el | • {{#if: UbuntuHelp:XenVirtualMachine|Ελληνικά| [[::XenVirtualMachine/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/es | • {{#if: UbuntuHelp:XenVirtualMachine|español| [[::XenVirtualMachine/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/fa | • {{#if: UbuntuHelp:XenVirtualMachine|فارسی| [[::XenVirtualMachine/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/fi | • {{#if: UbuntuHelp:XenVirtualMachine|suomi| [[::XenVirtualMachine/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/fr | • {{#if: UbuntuHelp:XenVirtualMachine|français| [[::XenVirtualMachine/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/gu | • {{#if: UbuntuHelp:XenVirtualMachine|ગુજરાતી| [[::XenVirtualMachine/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/he | • {{#if: UbuntuHelp:XenVirtualMachine|עברית| [[::XenVirtualMachine/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/hu | • {{#if: UbuntuHelp:XenVirtualMachine|magyar| [[::XenVirtualMachine/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/id | • {{#if: UbuntuHelp:XenVirtualMachine|Bahasa Indonesia| [[::XenVirtualMachine/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/it | • {{#if: UbuntuHelp:XenVirtualMachine|italiano| [[::XenVirtualMachine/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/ja | • {{#if: UbuntuHelp:XenVirtualMachine|日本語| [[::XenVirtualMachine/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/ko | • {{#if: UbuntuHelp:XenVirtualMachine|한국어| [[::XenVirtualMachine/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/ksh | • {{#if: UbuntuHelp:XenVirtualMachine|Ripoarisch| [[::XenVirtualMachine/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/mr | • {{#if: UbuntuHelp:XenVirtualMachine|मराठी| [[::XenVirtualMachine/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/ms | • {{#if: UbuntuHelp:XenVirtualMachine|Bahasa Melayu| [[::XenVirtualMachine/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/nl | • {{#if: UbuntuHelp:XenVirtualMachine|Nederlands| [[::XenVirtualMachine/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/no | • {{#if: UbuntuHelp:XenVirtualMachine|norsk| [[::XenVirtualMachine/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/oc | • {{#if: UbuntuHelp:XenVirtualMachine|occitan| [[::XenVirtualMachine/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/pl | • {{#if: UbuntuHelp:XenVirtualMachine|polski| [[::XenVirtualMachine/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/pt | • {{#if: UbuntuHelp:XenVirtualMachine|português| [[::XenVirtualMachine/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/ro | • {{#if: UbuntuHelp:XenVirtualMachine|română| [[::XenVirtualMachine/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/ru | • {{#if: UbuntuHelp:XenVirtualMachine|русский| [[::XenVirtualMachine/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/si | • {{#if: UbuntuHelp:XenVirtualMachine|සිංහල| [[::XenVirtualMachine/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/sq | • {{#if: UbuntuHelp:XenVirtualMachine|shqip| [[::XenVirtualMachine/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/sr | • {{#if: UbuntuHelp:XenVirtualMachine|српски / srpski| [[::XenVirtualMachine/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/sv | • {{#if: UbuntuHelp:XenVirtualMachine|svenska| [[::XenVirtualMachine/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/th | • {{#if: UbuntuHelp:XenVirtualMachine|ไทย| [[::XenVirtualMachine/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/tr | • {{#if: UbuntuHelp:XenVirtualMachine|Türkçe| [[::XenVirtualMachine/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/vi | • {{#if: UbuntuHelp:XenVirtualMachine|Tiếng Việt| [[::XenVirtualMachine/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/yue | • {{#if: UbuntuHelp:XenVirtualMachine|粵語| [[::XenVirtualMachine/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/zh | • {{#if: UbuntuHelp:XenVirtualMachine|中文| [[::XenVirtualMachine/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/zh-hans | • {{#if: UbuntuHelp:XenVirtualMachine|中文(简体)| [[::XenVirtualMachine/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:XenVirtualMachine | UbuntuHelp:XenVirtualMachine | {{#if: | :}}XenVirtualMachine}}/zh-hant | • {{#if: UbuntuHelp:XenVirtualMachine|中文(繁體)| [[::XenVirtualMachine/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:XenVirtualMachine|:XenVirtualMachine|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#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:
if you are using the Ubuntu server distribution.sudo mkinitramfs -o /boot/xen0-linux-2.6.17-6-server-xen0.initrd.img 2.6.17-6-server-xen0
- 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']
- Generate loopback file as sparse file (not written entirely to disk but filled on demand:
- 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']
- If e.g /dev/hda6 is our raw unformated partiton create a ext3-filesystem:
- 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 UbuntuHelp: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)
- 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