分类: LINUX
2011-02-06 22:54:37
首先最小化安装 CentOS,然后安装编译 Xen 和 Linux xen kernel 所需要的软件包:
# yum groupinstall "Development Tools" # yum install hmaccalc ncurses-devel zlib-devel openssl-devel python-devel \ bridge-utils libtool-ltdl iasl xorg-x11-drv-evdev xorg-x11-drv-fbdev \ xorg-x11-drv-i810-devel xorg-x11-drv-via-devel xorg-x11-proto-devel \ xorg-x11-server-sdk xorg-x11-xtrans-devel
安装完以上软件包后,剩下的操作就和 差不多了。
到 下载最新的 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
加入到启动脚本:
# /sbin/chkconfig --add xend # /sbin/chkconfig --add xendomains # /sbin/chkconfig xend on # /sbin/chkconfig xendomains on
下载 Linux 内核后给内核打 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
配置带 xen 的 Linux 内核:
$ 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 modules # make modules_install # make install # /sbin/depmod 2.6.31.8
更新 grub:
# vi /boot/grub/menu.lst ... title CentOS (2.6.31.8-xen) root (hd0,0) kernel /xen-4.0.0.gz module /vmlinuz-2.6.31.8 ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.31.8.img ...
重启系统,确认 Xen 安装成功:
# reboot # uname -a Linux localhost.localdomain 2.6.31.8 #2 SMP Tue Apr 20 11:19:19 SAST 2010 x86_64 GNU/Linux # xm list Name ID Mem VCPUs State Time(s) Domain-0 0 3713 4 r----- 36.0