我是007 发表于 2015-10-11 13:28:34

Centos5.6-xen4.0.3内核编译



编译过程




安装编译过程所需库和工具


yum -y groupinstall "Development Libraries"

yum -y groupinstall "Development Tools"

yum -y install transfig wget texi2html libaio-devel dev86 glibc-devel e2fsprogs-devel gitk mkinitrd iasl xz-devel bzip2-devel pciutils-libs pciutils-devel SDL-devel libX11-devel gtk2-devel bridge-utils PyXML qemu-common qemu-img mercurial glibc-devel




安装rpmforge库


wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm

rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

rpm -K rpmforge-release-0.5.1-1.el5.rf.*.rpm

rpm -i rpmforge-release-0.5.1-1.el5.rf.*.rpm

yum check-update




安装mercurial和git


yum -y install mercurial git


编译xen


hg clone http://xenbits.xen.org/xen-4.0-testing.hg

cd xen-4.0-testing.hg

make -j16 xen

make -j16 tools

make -j16 stubdom




编译pvops内核


make kernels


[*]make kernels时通常用的是自带的配置文件,少东西,我用官网给的2.6.32.43的配置文件重新编译:


make clean

cp -a .config .config-old wget -O .config http://pasik.reaktio.net/xen/kernel-config/config-2.6.32.43-pvops-dom0-xen-stable-x86_64

make oldconfig

make menuconfig



要修改一些内核配置,保证如下配置:

CONFIG_ATA=m

CONFIG_ATA_PIIX=m

CONFIG_USB_EHCI_HCD=m

CONFIG_USB_OHCI_HCD=m

CONFIG_USB_OHCI_HCD=m

CONFIG_XEN_NETDEV_BACKEND=m

CONFIG_XEN_BLKDEV_BACKEND=m

CONFIG_XEN_BLKBACK_PAGEMAG=m

CONFIG_SYSFS_DEPRECATED_V2=m

CONFIG_XEN_PCIDEV_BACKEND_VPCI=y





在menuconfig里把xen桥接选项改为*



重新编译:

make kernels

make -j16 dist




安装xen和新内核


make install-xen

make install-tools PYTHON_PREFIX_ARG=

cd build-*

make modules_install

make install




创建initrd.img文件


depmod 2.6.32.44

mkinitrd -v -f /boot/initrd-2.6.32.44.img 2.6.32.44




修改grub


在新内核标题下修改: 形式如下:

   root   (hd0,0)
kernel/xen-4.0.gz
module/vmlinuz-2.6.32.44 root=/dev/cciss/c0d0p1 ro
module/initrd-2.6.32.44.img


别忘了修改默认启动项!




修改/etc/modprobe.conf


添加如下: install xen /sbin/modprobe xen-evtchn; /sbin/modprobe xen-netback; /sbin/modprobe xenfs; /sbin/modprobe xen-blkback; /bin/true




修改/etc/fstab


添加如下: none /proc/xen xenfs defaults 0 0




修改/etc/xen/xend-config.sxp


(xend-http-server yes)

(xend-unix-server yes)

(xend-port 8000)

(xend-relocation-port 8002)




reboot


在启动xend服务之前手动加载 modprobe -l | grep xen 所列出模块。








使用vhd


在该版本xen中,要打两个补丁:







diff -r a672af698bc3 tools/python/xen/util/blkif.py

--- a/tools/python/xen/util/blkif.py    Fri Jul 09 12:35:58 2010 +0100

+++ b/tools/python/xen/util/blkif.py    Sun Jul 11 12:13:34 2010 +0400

@@ -87,7 +87,10 @@

               fn = "/dev/%s" %(fn,)

               

         if typ in ("tap", "tap2"):

-            (taptype, fn) = fn.split(":", 1)

+            if fn.count(":") == 1:

+                (taptype, fn) = fn.split(":", 1)

+            else:

+                (taptype, fn) = fn.split(":", 2)

   return (fn, taptype)

def blkdev_uname_to_file(uname):







diff -r 2c3495f3ca84 tools/python/xen/xend/XendBootloader.py
--- a/tools/python/xen/xend/XendBootloader.pyFri Jun 04 10:50:55 2010 +0100
+++ b/tools/python/xen/xend/XendBootloader.pySun Jun 06 23:48:50 2010 +0400
@@ -38,10 +38,15 @@
msg = "Bootloader isn't executable"
log.error(msg)
raise VmError(msg)
-    if not os.access(disk, os.R_OK):
-      msg = "Disk isn't accessible"
-      log.error(msg)
-      raise VmError(msg)
+    attempt = 0
+    while True:
+      if not os.access(disk, os.R_OK) and attempt > 3:
+            msg = "Disk isn't accessible"
+            log.error(msg)
+            raise VmError(msg)
+      else:
+            break
+      attempt = attempt + 1
if os.uname() == "NetBSD" and disk.startswith('/dev/'):
disk = disk.replace("/dev/", "/dev/r")



之后,重新编译tools:

make tools

make install-tools PYTHON_PREFIX_ARG=

reboot





相关命令如下:

例:

创建:vhd-util create -n MyVHDFile -s 1024

快照:vhd-util snapshot -n MyVHDFile -p SomeRawFile -m      ㎎为父映像。

在配置文件中:

disk = ['tap2:tapdisk:vhd:<VHD FILENAME>,xvda,w']

版权声明:本文为博主原创文章,未经博主允许不得转载。
页: [1]
查看完整版本: Centos5.6-xen4.0.3内核编译