在Ubuntu上源码安装Xen终于测试成功了!配合较新版本的Virt-manager和Virt-Viewer可以顺利的安装多个不同种类的操作系统。
首先,安装系统更新,更新管理器中的更新,语言支持更新等。
#sudo apt-get update
#sudo apt-get upgrade
禁用网络管理器,没有测试是否必需。
#sudo apt-get install chkconfig vim aptitude
chkconfig network-manager off
vim /etc/network/interfaces
修改为如下文本:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
重新启动网络服务:
/etc/init.d/networking restart
安装第一步,安装编译工具
#sudo apt-get install build-essential libssl-dev bzip2 gettext zlib1g-dev Python libncurses5-dev libjpeg62-dev libx11-dev libgcrypt11-dev pkg-config bridge-utils bcc bin86 libpci-dev libsdl-dev python-dev texinfo libc6-dev uuid-dev bison flex fakeroot crash kexec-tools makedumpfile libncurses5 libncurses5-dev iasl linux-headers-`uname -r`
#sudo apt-get install bcc bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools transfig tgif texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended pciutils-dev mercurial build-essential make gcc libc6-dev zlib1g-dev python python-dev python-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libjpeg62-dev iasl libbz2-dev e2fslibs-dev git-core uuid-dev ocaml libx11-dev
#sudo apt-get install libcurl4-openssl-dev xserver-xorg-dev mercurial gitk build-essential libncurses5-dev uuid-dev gawk gettext texinfo bcc libncurses5-dev dpkg-dev debhelper iasl texinfo bridge-utils bison flex kernel-package fakeroot
#apt-get build-dep xen-3.3
对于64位Ubuntu:
#apt-get install gcc-multilib
如果安装中出现Could not open file /var/lib/apt/lists/extras.ubuntu.com_ubuntu_dists_maverick_main_source_Sources-open的错误
请输入sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 16126D3A3E5C1192
这里,解决这个问题需要保证你的机器可以顺利连接keyserver.ubuntu.com
安装第二步,获取最新的打过Xen补丁的内核
#cd /usr/src
#git clone git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git linux-2.6-xen
#cd linux-2.6-xen
#git checkout -b xen/stable-2.6.32.x origin/xen/stable-2.6.32.x
此内核用git直接下载,约500M,花费时间较长,要确保git可以连接该服务器。
建议对首次下载的内核文件进行压缩打包备份,方便下次直接使用。
安装第三步,编译内核
在编译内核之前,应先设置内核的配置文件,这里我们提供一个.config文件点击下载附件,直接copy到内核的目录覆盖原文件即可。注意.config是隐藏文件
#aptitude install kernel-package fakeroot
#export CONCURRENCY_LEVEL=(number_of_cores)+1
#make-kpkg clean
#fakeroot make-kpkg --initrd --append-to-version=-pv kernel-image kernel-headers
如果出现/usr/bin/make -j (number_of_cores)+1的编译错误,请把(number_of_cores)+1改为(number_of_cores)再编译
编译内核后修改#vim /etc/modules
# /etc/modules: kernel modules to load at boot time.
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
lp
rtc
xen-evtchn
xen-gntdev
xen-netback
xen-blkback
xenfs
blktap