Xen 安装和PV Guest配置

一.Xen & Dom0 kernel 配置

1. 下载xen:

>hg clone http://xenbits.xensource.com/xen-unstable.hgxen-unstable

2. 选择某个changeset

>cdxen-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);\

手动下载qemu

>cd tools

>git clone http://xenbits.xensource.com/git-http/qemu-xen-unstable.git ioemu-remote

建立软连接

>ln –sf ioemu-remote ioemu-dir

有些版本在编译tools时需要iasa

>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

修改config/Linux.mk

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

制作initrd

>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

修改config/Linux.mk

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

在/etc/securetty末尾添加一行

“xvc0”

补充:

如果使用2.6-pvops作为PV Guestkernel的话,使用的是hvc终端在/etc/inittab添加一行

7:2345:respawn:/sbin/mingetty hvc0

在/etc/securetty末尾添加一行

“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

你让我尝到了每时每刻想你的疼苦,

Xen 安装和PV Guest配置

相关文章:

你感兴趣的文章:

标签云: