一.Xen & Dom0 kernel 配置
1. 下載xen:
>hg clone http://xenbits.xensource.com/xen-unstable.hg xen-unstable
2. 選擇某個changeset
>cd xen-unstable
>hg co 23000
3. 下載dom0 kernel
>git clone git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.gitlinux-2.6-pvops.git
4. 配置xen和dom0 kernel
- 將配置好的enable-xen-config拷貝至buildconfigs/,覆蓋原來的設定檔
>make linux-2.6-pvops-config 將產生build-linux-2.6-pvops_x86_64目錄
- 將配置好的linux-pvops-x86_64.config拷貝至build-linux-2.6-pvops_x86_64/.config
- 如果沒有配置好的檔案就自行配置,如要配置xen,直接make xen,如要配置dom0 kernel,直接make linux-2.6-pvops-config
5. 編譯前的準備
- 由於每次編譯tools,ioemu-remote都會被刪除後重新下載,這導致速度很慢,所以建議將這個自動下載的指令碼去掉,手動下載,這需要修改tools/Makefile:
diff -rd428fa67abaa tools/Makefile---a/tools/Makefile Wed Mar 09 16:17:26 2011+0000+++b/tools/Makefile Wed Oct 26 15:02:512011 +0800@@ -90,9+90,6 @@ mkdir-p ioemu-dir; \ else\ if[ ! -d ioemu-remote ]; then \- rm -rf ioemu-remoteioemu-remote.tmp; \- mkdirioemu-remote.tmp; rmdir ioemu-remote.tmp; \- $(GIT) clone$(CONFIG_QEMU) ioemu-remote.tmp; \ if[ "$(QEMU_TAG)" ]; then \ cdioemu-remote.tmp; \ $(GIT)branch -D dummy >/dev/null 2>&1 ||:; \@@ -101,8+98,6 @@ fi; \ mvioemu-remote.tmp ioemu-remote; \ fi;\- rm -f ioemu-dir; \- ln -sf ioemu-remote ioemu-dir;\ fi set-e; \ $(absolutify_xen_root);\
>cd tools
>git clone
http://xenbits.xensource.com/git-http/qemu-xen-unstable.git ioemu-remote
>ln –sf ioemu-remote ioemu-dir
>wget –c
http://www.acpica.org/download/acpica-unix-20100121.tar.gz
>tar xvf acpica-unix-20100121.tar.gz
>cd acpica-unix-20100121
>cd compiler
>make
>cp iasl /usr/bin
6. 編譯
>make xen –j10
KERNELS ?= linux-2.6-pvops
>make kernels –j10
>make tools –j10
7. 安裝
- 編譯完成後,xen會產生一個xen-4.1.0-rc7-pre.gz檔案,dom0kernel會產生vmlinuz-2.6.32.41和System.map-2.6.32.41,這些都放在dist/install/boot/下面,將這些複製到/boot下面
- 對於tools的安裝
>cd tools
>make install
>mkinitrd –v –f –with=ahci–with=aacraid –with=sd_mod –with=scsi_mod /boot/initrd-2.6.32.41.img 2.6.32.41
8. 配置GRUB
Titile XEN 4.1 root(hd0,0) kernel/boot/xen-4.1.0-rc7-pre.gz module/boot/vmlinuz-2.6.32.41 ro root=/dev/sda1 biosdevname=0 module/boot/initrd-2.6..32.41.img
二. PV Guest 配置
1. 下載domU kernel
>cd xen-unstable
> hg clone
http://xenbits.xensource.com/linux-2.6.18-xen.hg linux-2.6.18-xen.hg
2. 配置kernel
>make linux-2.6-xenU-config
- 將配置好的config-2.6.18-xenU_x86_64拷貝至build-linux-2.6.18-xenU_x86_64/.config
3. 編譯domU kernel
KERNELS ?= linux-2.6-xenU
>make kernels –j10
- 這樣在dist/install/boot/下面就產生了vmlinuz-2.6.18.8-xenU,System.map-2.6.18.8-xenU
- 製作initrd
>mkinitrd –v –f –with=ahci –with=aacraid–with=sd_mod –with=scsi_mod dist/install/boot/initrd-2.6.18.8-xenU.img 2.6.18.8-xenU
4. 安裝HVM Guest
- 可以參考其他材料安裝一個HVM的disk image
5. 安裝PV Guest
- 假如製作的HVM diskimage放在~/centos.img
- 將該虛擬磁碟掛在至/mnt
>mount –t ext3 –o loop,offset=32256~/centos.img /mnt
>cpdist/install/boot/vmlinuz-2.6.18-xenU /mnt/boot
>cp dist/install/boot/System.map-2.6.18.8-xenU/mnt/boot
>cpdist/install/boot/initrd-2.6.18.8-xenU.img /mnt/boot
>cp /lib/modules/2.6.18.8-xenU/mnt/lib/modules/ -r
6. 修改Guest的grub
>vim /mnt/boot/grub/grub.conf
Title pv-kernel (2.6.18-xen) Root(hd0,0) Kernel/boot/vmlinuz-2.6.18.8-xenU console=xvc0 root=/dev/hda1 ro Initrd/boot/initrd-2.6.18.8-xenU.img
7. 配置console
- 2.6.18.8-xenU使用的是xvc終端
- 修改/etc/inittab
#Run gettys in standard runlevelsCo:2345:respawn:/sbin/agetty xvc0 9600vt100-nav
“xvc0”
補充:
- 如果使用2.6-pvops作為PV Guestkernel的話,使用的是hvc終端
- 在/etc/inittab添加一行
7:2345:respawn:/sbin/mingetty hvc0
“hvc0”
- /boot/grub/grub.conf中的參數修改console=hvc0
- 在/mnt/dev/下缺少一些裝置檔案,需要添加
>cd /mnt/dev
>mknod –m 660 console c 5 1
>mknod –m 660 null c 1 3
8. 寫設定檔
>vim /etc/xen/mypv.conf
Bootloader = “/usr/bin/pygrub”Memory = 256Name = “PV”Vcpus =1Vif = [ ‘mac=00:16:3e:00:00:11, bridge=eth1’] //具體看xend建立的橋接器名稱Disk = [ ‘file:/root/yewei/centos.img,had,w’]
9. 啟動PV guest
>xm create /etc/xen/mypv.conf –c