Windows image 制作
Posted Hi,云计算!
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Windows image 制作相关的知识,希望对你有一定的参考价值。
本版本制作的windows 支持 feather: 1. Disk Bus=SCSI 2.Tunnel网络环境下自动配置MTU 3.动态修改密码
准备环境
1.windows iso : http://10.110.176.250:8080/os/iso/windows/cn_windows_server_2008_r2_standard_enterprise_datacenter_and_web_with_sp1_vl_build_x64_dvd_617396.iso
2.virtio driver for windows: https://fedoraproject.org/wiki/Windows_Virtio_Drivers
3.cloudbase-init for X64: https://www.cloudbase.it/downloads/CloudbaseInitSetup_Beta_x64.msi
4.qemu-guest-agent for windows: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-qemu-ga/
5.cloudbase-init patch for set mtu: https://review.openstack.org/#/c/389559/
安装过程
1.使用Libvirt 创建windows虚机,启动虚机的 XML 如下:
1 <domain type=‘kvm‘> 2 <name>win2012</name> 3 <uuid>6828e3f8-b517-4612-bad9-c6050d936e85</uuid> 4 <memory unit=‘KiB‘>2097152</memory> 5 <currentMemory unit=‘KiB‘>2097152</currentMemory> 6 <vcpu placement=‘static‘ cpuset=‘1-3‘>2</vcpu> 7 <cputune> 8 <shares>1024</shares> 9 </cputune> 10 <sysinfo type=‘smbios‘> 11 <system> 12 <entry name=‘manufacturer‘>Fedora Project</entry> 13 <entry name=‘product‘>OpenStack Nova</entry> 14 <entry name=‘version‘>13.0.0-1.el7</entry> 15 <entry name=‘serial‘>65fbc0c9-3e85-43c8-abf2-e6f3a26e2ffb</entry> 16 <entry name=‘family‘>Virtual Machine</entry> 17 </system> 18 </sysinfo> 19 <os> 20 <type arch=‘x86_64‘ machine=‘pc-i440fx-rhel7.0.0‘>hvm</type> 21 <boot dev=‘cdrom‘/> 22 <boot dev=‘hd‘/> 23 <smbios mode=‘sysinfo‘/> 24 </os> 25 <features> 26 <acpi/> 27 <apic/> 28 </features> 29 <cpu mode=‘host-model‘> 30 <model fallback=‘allow‘/> 31 <topology sockets=‘1‘ cores=‘2‘ threads=‘1‘/> 32 </cpu> 33 <clock offset=‘utc‘> 34 <timer name=‘pit‘ tickpolicy=‘delay‘/> 35 <timer name=‘rtc‘ tickpolicy=‘catchup‘/> 36 <timer name=‘hpet‘ present=‘no‘/> 37 </clock> 38 <on_poweroff>destroy</on_poweroff> 39 <on_reboot>restart</on_reboot> 40 <on_crash>destroy</on_crash> 41 <devices> 42 <emulator>/usr/libexec/qemu-kvm</emulator> 43 <disk type=‘file‘ device=‘disk‘> 44 <driver name=‘qemu‘ type=‘qcow2‘/> 45 <source file=‘/home/stack/images/win2012.qcow2‘/> 46 <target dev=‘sda‘ bus=‘scsi‘/> 47 <address type=‘drive‘ controller=‘0‘ bus=‘0‘ target=‘0‘ unit=‘0‘/> 48 </disk> 49 <disk type=‘file‘ device=‘cdrom‘> 50 <driver name=‘qemu‘ type=‘raw‘/> 51 <source file=‘/home/stack/windows/cn_windows_server_2012_r2_x64_dvd_2707961.iso‘/> 52 <target dev=‘hda‘ bus=‘ide‘/> 53 <readonly/> 54 <address type=‘drive‘ controller=‘0‘ bus=‘0‘ target=‘0‘ unit=‘0‘/> 55 </disk> 56 <disk type=‘file‘ device=‘cdrom‘> 57 <driver name=‘qemu‘ type=‘raw‘/> 58 <source file=‘/home/stack/windows/virtio-win.iso‘/> 59 <target dev=‘hdd‘ bus=‘ide‘/> 60 <readonly/> 61 <address type=‘drive‘ controller=‘0‘ bus=‘1‘ target=‘0‘ unit=‘0‘/> 62 </disk> 63 <interface type=‘network‘> 64 <mac address=‘52:54:00:f4:71:33‘/> 65 <source network=‘default‘/> 66 <model type=‘e1000‘/> 67 <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x03‘ function=‘0x0‘/> 68 </interface> 69 <serial type=‘pty‘> 70 <target port=‘0‘/> 71 </serial> 72 <console type=‘pty‘> 73 <target type=‘serial‘ port=‘0‘/> 74 </console> 75 <input type=‘tablet‘ bus=‘usb‘/> 76 <input type=‘mouse‘ bus=‘ps2‘/> 77 <input type=‘keyboard‘ bus=‘ps2‘/> 78 <graphics type=‘vnc‘ port=‘-1‘ autoport=‘yes‘ listen=‘0.0.0.0‘ keymap=‘en-us‘> 79 <listen type=‘address‘ address=‘0.0.0.0‘/> 80 </graphics> 81 <video> 82 <model type=‘qxl‘ ram=‘65536‘ vram=‘65536‘ vgamem=‘16384‘ heads=‘1‘/> 83 <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x02‘ function=‘0x0‘/> 84 </video> 85 <memballoon model=‘virtio‘> 86 <stats period=‘10‘/> 87 <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x05‘ function=‘0x0‘/> 88 </memballoon> 89 </devices> 90 </domain>
注意:1.多个CPU 2.Disk bus SCSI
2.创建 leuser账户,禁用Administrator
3.安装qemu-guest-agent, 用户支持动态修改密码
4.安装Virtio driver,参见: https://goo.gl/ckgdWN
注意.qemu-guest-agent 的driver需重机关、编辑XML、重启,XML修改如下:
1 <channel type=‘unix‘> 2 <source mode=‘bind‘ path=‘/var/lib/libvirt/qemu/win7x86.agent‘/> 3 <target type=‘virtio‘ name=‘org.qemu.guest_agent.0‘/> 4 <address type=‘virtio-serial‘ controller=‘0‘ bus=‘0‘ port=‘1‘/> 5 </channel>
5.内存监控
在 Windows 2008r2 and Windows 2012/Win8 :
Copy and rename as Administrator the WIN7AMD64 directory from the virtio.iso to “c:/Program files/Balloon”
Open a CMD as Administrator and cd into “c:/Program Files/Balloon”
Install the BLNSVR with “BLNSVR.exe -i”
在 Windows 2003 / Windows Xp :
Download the “devcon” software on microsoft website kb311272
devcon install BALLOON.inf “PCIVEN_1AF4&DEV_1002&SUBSYS_00051AF4&REV_00”
6.安装cloudbase-init
1).修改cloudbase-init.conf的参数metadata_services和plugins
参数配置如下:
1 metadata_services=cloudbaseinit.metadata.services.configdrive.ConfigDriveService,cloudbaseinit.metadata.services.httpservice.HttpService,cloudbaseinit.metadata.services.ec2service.EC2Service,cloudbaseinit.metadata.services.maasservice.MaaSHttpService 2 plugins=cloudbaseinit.plugins.windows.mtu.MTUPlugin,cloudbaseinit.plugins.windows.ntpclient.NTPClientPlugin,cloudbaseinit.plugins.windows.createuser.CreateUserPlugin,cloudbaseinit.plugins.windows.networkconfig.NetworkConfigPlugin,cloudbaseinit.plugins.windows.sshpublickeys.SetUserSSHPublicKeysPlugin,cloudbaseinit.plugins.windows.userdata.UserDataPlugin,cloudbaseinit.plugins.windows.setuserpassword.SetUserPasswordPlugin,cloudbaseinit.plugins.windows.localscripts.LocalScriptsPlugin
2).替换cloudbase-init文件,支持设置configDriver配置MTU,具体参见commit: https://review.openstack.org/#/c/389559/ 修改的文件如下:
1 cloudbaseinit/metadata/services/base.py 2 cloudbaseinit/metadata/services/opennebulaservice.py 3 cloudbaseinit/plugins/common/networkconfig.py 4 cloudbaseinit/tests/metadata/fake_json_response.py 5 cloudbaseinit/tests/metadata/services/test_baseopenstackservice.py 6 cloudbaseinit/tests/metadata/services/test_opennebulaservice.py 7 cloudbaseinit/tests/plugins/common/test_networkconfig.py 8 cloudbaseinit/tests/utils/test_debiface.py 9 cloudbaseinit/utils/debiface.py
上传镜像
命令行:
1 glance image-create --name "win2K8_r2_x64" --disk-format qcow2 --container-format bare --progress < /home/stack/win2012.qcow2 2 3 glance image-update --property hw_disk_bus=scsi --property hw_cpu_sockets=2 --property hw_qemu_guest_agent=yes --property os_admin_user=leuser win2K8_r2_x64
创建虚机
命令行如下:
1 nova boot --config-drive=true --image win2K8_r2_x64 --key-name controller --flavor windowsc2m1024d20 --nic net-id=4c85a0e2-7fd8-40e1-8746-95c03ad7aecb instance-001
注:管理 windows 的MTU
1.netsh interface ip show interface
2.netsh interface ip set subinterface "本地连接 2" mtu=1450 store=persistent
参考文档:
http://wiki.letv.cn/display/pla/2014.09.22+-+2014.09.26
http://docs.openstack.org/image-guide/windows-image.html
https://pve.proxmox.com/wiki/Qemu-guest-agent
http://wiki.stoney-cloud.org/wiki/Qemu_Guest_Agent_Integration
https://niusmallnan.github.io/_build/html/_templates/openstack/libvirt_memory_usage.html
以上是关于Windows image 制作的主要内容,如果未能解决你的问题,请参考以下文章
python 用于在终端中运行的sublime text 3的简单代码片段制作工具
在 Windows 8/Metro/Store 中为 RectangleGeometry(在 Image.Clip 中)设置动画