个人工具

UbuntuHelp:XenOnUbuntuBinaryInstall

来自Ubuntu中文

Oneleaf讨论 | 贡献2007年5月24日 (四) 14:12的版本 (新页面: {{From|https://help.ubuntu.com/community/XenOnUbuntuBinaryInstall}} {{Languages|UbuntuHelp:XenOnUbuntuBinaryInstall}} NOTE: This document appears to be newer, https://wiki.ubuntu.com/Xen...)

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航, 搜索


NOTE: This document appears to be newer, https://wiki.ubuntu.com/XenOnEdgy

Overview

This How To describes the installation of Xen Prebuilt Binaries for Ubuntu (works with Breezy and Dapper). More How-To's listed at the bottom describe other ways, including the more complex building of the Xen kernel. This how-to presumes a second hard disk (hdb) where the lvm will reside. You may easily format and partition your single hard drive to use lvm, and modify the how-to accordingly.

This begins with a clean install, server configuration (no GUI), and installs the prebuilt kernel and other binaries required to run Xen 3.0.

Installing Ubuntu

Boot to the Ubuntu install cd, and type/select server to install a minimal OS with no GUI. While Reiser FS is considered faster, some people have had problems running Xen and Reiser, so ext3 (the default) or xfs may be a better choice.

Choose default options, leaving the second hard drive untouched, finish the installation, and login.

Configuring the system

All commands here are sudo; you may type sudo -s to switch to sudo for this session.

apt-get update
apt-get upgrade
apt-get install iproute python python-twisted bridge-utils

If you have problems connecting, check NetworkNotEnabled to see if your ethernet card is activated.

Download the Tarballed Pre-built installations of Xen 3.0 (you'll probably choose 'for 32 bit') from XenSource. Untar it, changing the command so version numbers match, with

tar xvf xen-3.0.2-install-x86_32.tgz

In the untared xen directory, type sh install.sh

Check for error messages - it should say OK to all.

/sbin/depmod -a 2.6.16-xen (change this line if needed to match what is in your /lib/modules)

cd /boot/grub

Edit using your favorite text editor, edit menu.lst, placing the following lines BEFORE the Automagic section (check your /boot folder to see if the following lines point to the correct files):

title Xen 3.0 / XenLinux 2.6
kernel /boot/xen-3.gz dom0_mem=128M
module /boot/vmlinuz-2.6-xen root=/dev/hda1 ro

Reboot!

NOTE: If you are using SCSI drives, or any that need to load drivers before the file system is accessed, you will need a new initrd image.

cd /boot
mkinitramfs -o initrd.img-2.6.16-xen 2.6.16-xen 

Then, in menu.lst under your already entered module line, place:

module /boot/initrd.img-2.6.16-xen

NOTE: if you get the message "Error 15: File not found" when you boot, then try changing menu.lst to the following:

title Xen 3.0 / XenLinux 2.6
kernel /xen-3.gz dom0_mem=128M
module /vmlinuz-2.6-xen root=/dev/hda1 ro

NOTE: if you are using SATA drives, you may have a kernel panic error message. This appears to be due to the limited set of drivers that come with the Xen pre-built kernel. This appears to affect Xen 3.0.2 but not 2.0.7

Check your kernel by typing uname -r and you should see 2.6.16-xen.

/lib/tls error

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.

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

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


Dom0 Xorg nvidia

If you are trying to install xen on a Ubuntu Desktop machine, Xorg with original nvidia drivers will fail. You can try to follow this tutorial: UbuntuHelp:XenVirtualMachine/NVidiaOnXenOnUbuntuEdgy.

Ubuntu Specific Configurations

If you want to have xend start automatically, update your init.d by entering the following commands:

update-rc.d xend defaults 20 21
update-rc.d xendomains defaults 21 20

Peter Fokkinga suggests modifying /etc/init.d/xend, adding these lines near the beginning of the file (after the "grep -q ..." block)

# on Ubuntu (Debian too?) /var/run/xenstored does not exist after reboot
if [ ! -d /var/run/xenstored ] ; then
mkdir /var/run/xenstored
fi

and in /etc/init.d/xendomains, change LOCKFILE=/var/lock/subsys/xendomains to LOCKFILE=/var/lock/xendomains

Is xen running properly? Type xm list and you should see Domain-0; if not, reboot and double check.

You may need to add an initrd line to your grub config. See here and and here for details. (Question - can someone tell me when I would need to do this? Does it depend on hardware?)

Further Tasks

Unneccesary packages

Some people suggest uninstalling unneccesary packages. You may choose to uninstall

apt-get remove ppp pppconfig pppoeconf

LVM

You can partition and format the remaining free space, and then use lvm to create logical volumes using Xen-LVM How-To.

(partial, untested information)

Presuming your lvm partitions are /dev/xen_lvm/dom1 and /dev/xen_lvm/dom1_swap

mkfs.ext3 /dev/xen_lvm/dom1
mkswap -f /dev/xen_lvm/dom1_swap
mkdir /xen
mount -t ext3 /dev/xen_lvm/dom1 /xen

You can now run debootstrap and install Ubuntu or Debian to /xen

Installing DomU w/ debootstrap (Partially Tested: please add any additional steps you had to take here)

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"

Start the DomU machine

xm create dom1.cfg -c

Ignore any modprobe: FATAL: Could not load /lib/modules/2.6.16-xen/modules.dep errors, they are harmless

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!

Additional Information

Below are some links to other pages from which I derived this method.