分类: LINUX
2011-02-06 22:54:11
首先最小化安装 Debian,然后安装编译 Xen 和 Linux xen kernel 所需要的软件包:
# apt-get install bcc bin86 gawk bridge-utils iproute libcurl3 \ libcurl4-openssl-dev bzip2 module-init-tools transfig tgif texinfo \ 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 uuid-dev iasl # apt-get build-dep linux
如果是64位系统的话,还需要安装:
# apt-get install gcc-multilib
到 下载最新的 Xen 源代码,然后解开、编译、安装,标准的 Linux 软件源码安装动作:
$ tar zxvf xen-4.0.0.tar.gz $ cd xen-4.0.0/ $ make xen tools stubdom # make install-xen install-tools install-stubdom
上面 make stubdom 的时候会从网上自动下载一些东西,所以如果是用代理上网的话需要在自己根目录下的 .wgetrc 里加上代理服务器,以便 wget 能通过代理正常下载:
$ vi .wgetrc http_proxy = use_proxy = on
加入到自动启动脚本中:
# update-rc.d xend defaults 20 21 # update-rc.d xendomains defaults 21 20
下载 xen 内核,给内核打补丁:
$ cd $ wget $ tar -xjf linux-2.6.31.8.tar.bz2 $ wget xen-patches-2.6.31-10.tar.bz2 $ mkdir xenpatch-2.6.31.8 $ cd xenpatch-2.6.31.8 $ tar -xjf ../xen-patches-2.6.31-10.tar.bz2 $ cd .. $ cd linux-2.6.31.8 $ for i in `ls ../xenpatch-2.6.31.8/`; \ do patch -p1 < ../xenpatch-2.6.31.8/"$i"; done
配置内核,直接把系统已经存在的配置文件拷过来然后在此基础上修改:
$ cp /boot/config-2.6.31-14-server .config $ make menuconfig Processor type and features ---> [*] Enable Xen compatible kernel Networking support ---> Networking options ---> <*> 802.1d Ethernet Bridging Device Drivers ---> XEN ---> [*] Privileged Guest (domain 0)Backend driver support Block-device backend driver Block-device tap backend driver Block-device tap backend driver 2 Network-device backend driver PCI-device backend driver SCSI backend driver USB backend driver <*> Block-device frontend driver <*> Network-device frontend driver SCSI frontend driver USB frontend driver <*> Framebuffer-device frontend driver <*> Keyboard-device frontend driver [*] Disable serial port drivers <*> Export Xen attributes in sysfs Xen version compatibility (3.3.0 and later) ---> 3.3.0 and later
配置好内核参数以后,保存配置文件、退出配置界面就可以开始编译 Linux 内核了:
$ make # make install # make modules_install # update-initramfs -c -k 2.6.31.8 # depmod 2.6.31.8
如果 Xen 加了内核模块的话加入 /etc/modules 文件以便启动时候自动加载:
# vi /etc/modules ... netbk blkbk
更新 grub:
# update-grub # vi /boot/grub/menu.lst
重新启动系统,就应该可以进入 dom0 了:
# reboot # uname -a Linux debian 2.6.31.8 #1 SMP Sat Apr 17 09:26:20 SAST 2010 x86_64 GNU/Linux # xm list Name ID Mem VCPUs State Time(s) Domain-0 0 3713 4 r----- 48.7