2012年7月4日 星期三

ubuntu 11.04編譯安裝xen4.1.2遇到問題與解決

按照這個網站的步驟編譯安裝xen


http://blog.jeoygin.org/2011/04/ubuntu-natty-install-xen-4.html






make xen tools stubdom<<這部會出現erro
原因是少安裝一個檔案,需要apt-get install 安裝起來
 sudo apt-get install  ocaml-findlib






編譯kernel的時候需要把xen相關選項打開


Processor type and features --->
[*] Enable Xen compatible kernel


Networking support --->
Networking options --->
<*> 802.1d Ethernet Bridging

Device Drivers --->
XEN --->
[*] Privileged Guest (domain 0)
[m]Backend driver support
[m]Block-device backend driver
[m]Block-device tap backend driver
[m]Block-device tap backend driver 2
[m]Network-device backend driver
<*> Export Xen attributes in sysfs
Xen version compatibility (no compatibility code) --->
no compatibility code
intel網卡driver因為實驗關係而關掉igb 與igbvf
Device Drivers --->
Networking device support --->
Ethernet(1000Mbit) --->
<>Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support
  <>Intel(R) 82576 Virtual Function Ethernet suppport

Enable Xen compatible kernel
256要改成255



Device Drivers --->
Xen driver support--->
<*>Xen /dev/xen/evtchn device




grub設定 
從grub2降級成grub之後 設定menu.lst要記得看vmlinuz版本 initrd.img檔案 kernel版本 還有UUID


重開機後
sudo /etc/init.d/xencommons start
因為4.1.0版本後不再使用xm所以使用xl


sudo xl list 查看dom0










------------------網站備份



一、準備源碼

  首先,為系統安裝需要的包:

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 g++ 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 bison flex libssl-dev gettext libgcrypt11-dev pkg-config fakeroot crash kexec-tools makedumpfile libncurses5
sudo apt-get build-dep linux
apt-get install gcc-multilib
apt-get install xz-utils
  下載源碼:
  Xen 4.0.1http://bits.xensource.com/oss-xen/release/4.0.1/xen-4.0.1.tar.gz
  Linux Kernel 2.6.38.4http://www.kernel .org/pub/linux/kernel/v2.6/linux-2.6.38.4.tar.gz

  還需要下載內核的xen補丁:
  xen-patches-2.6.38-2http://gentoo-xen-kernel.googlecode.com/files/xen-patches-2.6.38-2.tar.bz2

  將所有包移動到/usr/src後展開各個包:

sudo tar zxvf linux-2.6.38.4.tar.gz
sudo tar zxvf xen-4.0.1.tar.gz
sudo mkdir xen-patches
cd xen-patches
tar jxvf ../xen-patches-2.6.38-2.tar.bz2
  進入linux-2.6.38.4目錄,打上補丁:

sudo cat ../xen-patches/*.patch1 | patch -p1
二、編譯Xen

make xen tools stubdom
make install-xen
make install-tools PYTHON_PREFIX_ARG=
make install-stubdom
  在編譯的過程中可能會遇到如下問題:

In file included from tapdisk.h:62:0,
from blk_linux.c:4:
../lib/blktaplib.h:199:0: error: "WRITE" redefined
/usr/include/linux/fs.h:160:0: note: this is the location of the previous definition
  這個問題請打補丁:blk_linux.patch1

netfront.c:41:32: error: variably modified 'tx_freelist' at file scope
netfront.c:44:34: error: variably modified 'rx_buffers' at file scope
netfront.c:45:34: error: variably modified 'tx_buffers' at file scope
lib/math.c: In function '__qdivrem':
lib/math.c:196:9: error: 'tmp.ul[1]' may be used uninitialized in this function
mm.c: In function 'set_readonly':
mm.c:321:46: error: taking address of expression of type 'void'
  這個問題請打補丁:gcc-4.5.patch1

  如果使用xm命令報以下錯誤:

AttributeError: HTTPUnix instance has no attribute 'getresponse'
  請打補丁:xmlrpc.patch1

三、編譯內核

  先準備一個編譯配置,可以下載我使用的配置.config,執行make menuconfig命令,配置好內核參數後,保存配置文件,之後就可以開始編譯了:

sudo make
sudo make install
sudo make modules_install
sudo update-initramfs -c -k 2.6.38.4
sudo depmod 2.6.38.4
  將Xen的內核模塊加入/etc/modules文件,使系統啟動時自動加載:

sudo vi /etc/modules
...
netbk
blkbk
blktap
四、修改grub

  Ubuntu 11.04 使用了Grub2,Grub2Xen是不兼容的,於是將grub2降級到grub

sudo apt-get purge grub-pc
sudo rm /boot/grub/*
sudo apt-get install grub
sudo grub-install --recheck /dev/sda
sudo update-grub
  手動添加啟動菜單,/boot/grub/menu.lst中添加以下內容:

title Xen 4.0.1 / Linux 2.6.38.4
kernel /boot/xen-4.0.gz
module /boot/vmlinuz-2.6.38.4 root=[root-location] ro cnsole=tty0
module /boot/initrd.img-2.6.38.4
  重啟,不出意外的話xen應該是啟動了,可以使用以下命令查看:

ps -ef | grep xend
xm list


沒有留言:

張貼留言