在CentOS下通过源码 编译安装Xen 4.1.1

直入主题,本文写给希望在CentOS系统中安装Xen虚拟化环境的朋友。请使用前仔细阅读本文,如果您尚不熟悉Linux终端操作,请移步。

Step.1 安装需要的软件包:

首先最小化安装 CentOS,首先使用yum升级系统

# yum update

然后安装编译 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
 
http://www.acpica.org/downloads下载并安装acpica,进入解压缩包中的compiler目录中,
# make
# make install
 
Step.2 安装 Xen hypervisor:
http://www.xen.org/products/xen_source.html 下载最新的 Xen 源代码,然后解开、编译、安装,标准的 Linux 软件源码安装动作:
# tar zxvf xen-4.1.1.tar.gz
# cd xen-4.1.1/
# make world
(此过程耗时约10-15分钟)
# make install
 
Step.3 将Xen加入到启动脚本:
# /sbin/chkconfig --add xend
# /sbin/chkconfig --add xendomains
# /sbin/chkconfig --add xencommons
# /sbin/chkconfig xend on
# /sbin/chkconfig xendomains on
# /sbin/chkconfig xencommons on
 
Step.4 下载、配置并编译 Xen 内核:

下载 Linux 内核后给内核打 xen 补丁:

$ cd
$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.8.tar.bz2
$ tar -xjf linux-2.6.31.8.tar.bz2
$ wget http://gentoo-xen-kernel.googlecode.com/files/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

$ 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
注意:如果使用32位系统,则务必将PAE功能开启,将内存支持选择为64GB,否则会重启后内核将会报错。
Processor type and features --->
   High Memory Support (4GB) --->
      64GB

配置好内核参数以后,保存并退出,开始编译 Linux 内核:
# make
(此过程耗时约30-45分钟)
# make modules
# make modules_install
# make install
# /sbin/depmod 2.6.31.8

Step.5 更新 grub 引导信息:

# vi /boot/grub/menu.lst
title CentOS (2.6.31.8-xen)
    root (hd0,0)
    kernel /xen-4.1.1.gz
    module /vmlinuz-2.6.31.8 ro root=/dev/VolGroup00/LogVol00
    module /initrd-2.6.31.8.img

相关推荐