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)[1:3]
     return (fn, taptype)
 def blkdev_uname_to_file(uname):


diff -r 2c3495f3ca84 tools/python/xen/xend/XendBootloader.py
--- a/tools/python/xen/xend/XendBootloader.py	Fri Jun 04 10:50:55 2010 +0100
+++ b/tools/python/xen/xend/XendBootloader.py	Sun 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()[0] == "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']

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章