一 、 Ubuntu 半虚拟模板制作
-----------------------------------------------------------------------------
1. 首先创造10G img文件
dd if=/dev/zero of=/opt/Xen/ubuntu-10.10.img bs=1024k count=10000
2.在网站:http://cdimage.ubuntu.com/netboot/ 选择OS,并下载相关文件
http://cn.archive.ubuntu.com/ubuntu/dists/precise/main/installer-amd64/current/images/netboot/xen/
下载文件:vmlinuz 及 initrd.gz
注:在网站:http://cn.archive.ubuntu.com/ubuntu/dists/ 或者http://archive.ubuntu.com/ 里面可以选择你所需要的版本安装下载
3.使用XML文件启动,如下:
<domain type='xen'>
<name>ubuntu</name>
<uuid>246de35e-7992-4618-8c79-ece9cd5d1d4f</uuid>
<memory>1024000</memory>
<currentMemory>1024000</currentMemory>
<vcpu>4</vcpu>
<!--bootloader>/usr/bin/pygrub</bootloader-->
<os>
<kernel>/opt/vmlinuz</kernel>
<initrd>/opt/initrd.gz</initrd>
<type>linux</type>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/opt/ubuntu-10.10.img'/>
<target dev='hda' bus='ide'/>
</disk>
<interface type='bridge'>
<mac address='00:16:3e:65:1d:4f'/>
<source bridge='xenbr0'/>
<script path='/etc/xen/scripts/vif-bridge'/>
<target dev='vif-1.0'/>
</interface>
<console type='pty'>
</console>
</devices>
</domain>
4,查找ubuntu ID 通过console 进行系统安装
xm list
xm console ID
系统安装与日常安装一样,此处略
5.安装完成后,使用如下文件启动:
<domain type='xen'>
<name>ubuntu</name>
<uuid>246de35e-7992-4618-8c79-ece9cd5d1d4f</uuid>
<memory>1024000</memory>
<currentMemory>1024000</currentMemory>
<vcpu>4</vcpu>
<bootloader>/usr/bin/pygrub</bootloader>
<os>
<!--kernel>/opt/vmlinuz</kernel>
<initrd>/opt/initrd.gz</initrd-->
<type>linux</type>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/opt/ubuntu-10.10.img'/>
<target dev='hda' bus='ide'/>
</disk>
<interface type='bridge'>
<mac address='00:16:3e:65:1d:4f'/>
<source bridge='xenbr0'/>
<script path='/etc/xen/scripts/vif-bridge'/>
<target dev='vif-1.0'/>
</interface>
<console type='pty'>
</console>
</devices>
</domain>
注意:写安装配置文档时,文件路径的正确性
二 、Centos Redhat 半虚拟模板制作
-----------------------------------------------------------------------------
与 Ubuntu 模板制作相同,在http://mirror.centos.org/centos/ 选择下载对应版本的vmlinuz 及 initrd.gz
Redhat 需要下载镜像解压到nfs或者FTP服务器上,再进行系统安装
三 、WINDOWS 全虚拟模板制作
-----------------------------------------------------------------------------
1,下载相关的 ISO 镜像 例如:win2008.iso
2,制作50G操作系统硬盘
dd if=/dev/zero of=/opt/Xen/win2008.img bs=1024k count=50000
3,创建配置文件进行系统安装
vim win2008.xml
<domain type='xen'>
<name>win2008</name>
<uuid>976124e0-aadb-4e33-a820-7306b9f2ecdd</uuid>
<memory>4097152</memory>
<currentMemory>4097152</currentMemory>
<vcpu>2</vcpu>
<os>
<type>hvm</type>
<loader>/usr/lib/xen/boot/hvmloader</loader>
<boot dev='cdrom'/> //设置从光盘启动
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
<disk type='file' device='cdrom'>
<driver name='file'/>
<source file='/win2008.iso'/>
<target dev='hdc' bus='ide'/>
</disk> // 设置光盘参数与光盘文件
<disk type='file' device='disk'>
<driver name='file'/>
<source dev='/win2008.img'/>
<target dev='hda' bus='ide'/>
</disk> // 设置系统硬盘
<interface type='bridge'>
<mac address='00:16:3e:29:40:80'/>
<source bridge='br0'/>
<script path='vif-bridge'/>
<target dev='vif-1.0'/>
</interface> //配置网卡
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
</devices>
</domain>
开启虚拟机进行系统安装
virsh create win2008.xml
通过VNC 远程安装系统
virsh vncdisplay ID
系统安装与日常光盘一样,此处略
4,开启虚拟机
<domain type='xen'>
<name>win2008</name>
<uuid>976124e0-aadb-4e33-a820-7306b9f2ecdd</uuid>
<memory>4097152</memory>
<currentMemory>4097152</currentMemory>
<vcpu>2</vcpu>
<os>
<type>hvm</type>
<loader>/usr/lib/xen/boot/hvmloader</loader>
<boot dev='hd'/> //设置从硬盘启动
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
<disk type='file' device='disk'>
<driver name='file'/>
<source dev='/win2008.img'/>
<target dev='hda' bus='ide'/>
</disk> // 设置系统硬盘
<interface type='bridge'>
<mac address='00:16:3e:29:40:80'/>
<source bridge='br0'/>
<script path='vif-bridge'/>
<target dev='vif-1.0'/>
</interface> //配置网卡
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
</devices>
</domain>
系统模板制作完成