创建HVM格式的CentOS虚拟机:

1、创建磁盘文件

[root@xen xen]# dd if=/dev/zero of=/images/xen/centos6-hvm.img bs=100M count=100

记录了100+0 的读入

记录了100+0 的写出

10485760000字节(10 GB)已复制,148.453 秒,70.6 MB/秒

2、编辑虚拟机配置文件

[root@xen opt]# vi /etc/xen/centos6-hvm.cfg 

[root@xen opt]# cat /etc/xen/centos6-hvm.cfg 

kernel = "hvmloader"

builder = 'hvm'

name = "centos6-hvm"

vcpus = 1

memory = 1024

on_reboot = 'destroy'

disk = [ 'file:/images/xen/centos6-hvm.img,hda,w','file:/opt/CentOS-6.5-x86_64-bin-DVD1.iso,hdc:cdrom,r' ]

vif = [ 'type=ioemu, bridge=br0' ]

vnc = 1

vnclisten = '0.0.0.0'

sdl = 0

boot = "dc"

3、创建虚拟机

[root@xen opt]# xl create /etc/xen/centos6-hvm.cfg 

4、安装系统

在XEN虚拟化环境中创建HVM模式虚拟机_第1张图片

在XEN虚拟化环境中创建HVM模式虚拟机_第2张图片

5、修改配置文件

[root@xen opt]# vi /etc/xen/centos6-hvm.cfg 

[root@xen opt]# cat /etc/xen/centos6-hvm.cfg 

kernel = "hvmloader"

builder = 'hvm'

name = "centos6-hvm"

vcpus = 1

memory = 1024

disk = [ 'file:/images/xen/centos6-hvm.img,hda,w' ]

vif = [ 'type=ioemu, bridge=br0' ]

vnc = 1

vnclisten = '0.0.0.0'

sdl = 0

boot = "dc"

on_poweroff = 'destroy'

on_reboot = 'restart'

on_crash = 'restart'

6、启动虚拟机,使用vncviewer连接并测试

[root@xen opt]# xl create /etc/xen/centos6-hvm.cfg

[root@xen opt]# vncviewer :5900

在XEN虚拟化环境中创建HVM模式虚拟机_第3张图片



创建HVM模式的winxp虚拟机:

1、创建虚拟机磁盘文件

[root@xen xen]# dd if=/dev/zero of=/images/xen/winxp.img bs=100M count=100

记录了100+0 的读入

记录了100+0 的写出

10485760000字节(10 GB)已复制,137.431 秒,76.3 MB/秒

2、创建虚拟机配置文件

[root@xen xen]# vi /etc/xen/winxp.cfg 

[root@xen xen]# cat /etc/xen/winxp.cfg 

kernel = "hvmloader"

builder = 'hvm'

name = "winxp"

vcpus = 1

memory = 1024

disk = [ 'file:/images/xen/winxp.img,hda,w','file:/opt/DBX_GHOST_XP_SP3_CJ_V3.5.iso,hdc:cdrom,r' ]

vif = [ 'type=ioemu, bridge=br0' ]

vnc = 1

vnclisten = '0.0.0.0'

sdl = 0

acpi = 1

apic = 1

boot = "dc"

on_reboot = 'destroy'

serial = 'pty'

usbdevice = 'tablet'

3、启动虚拟机

[root@xen xen]# xl create /etc/xen/winxp.cfg 

4、安装操作系统

在XEN虚拟化环境中创建HVM模式虚拟机_第4张图片

在XEN虚拟化环境中创建HVM模式虚拟机_第5张图片

5、修改配置文件

kernel = "hvmloader"

builder = 'hvm'

name = "winxp"

vcpus = 1

memory = 1024

disk = [ 'file:/images/xen/winxp.img,hda,w' ]

vif = [ 'type=ioemu, bridge=br0' ]

vnc = 1

vnclisten = '0.0.0.0'

sdl = 0

acpi = 1

apic = 1

boot = "dc"

on_reboot = 'restart'

on_shutdown = 'destroy'

on_crash = 'restart'

usbdevice = 'tablet'

6、使用新的配置文件重新启动虚拟机

[root@xen xen]# xl create /etc/xen/winxp.cfg