zoukankan      html  css  js  c++  java
  • openstack 制作 windows7 镜像

    为openstack制作可用的windows镜像,目前官方授权的只有 http://www.cloudbase.it/windows-cloud-images/ 提供的  windows server 2012 R2 Evaluation Cloud Image.我们在网站上能看到这样的字样。

    Microsoft Windows Server 2012 R2 Standard Evaluation is now available as a downloadable cloud image, customized by our engineers and ready to be be directly deployed in OpenStack.

    理论上来说这个镜像是可以直接使用glance部署到我们的openstack 上。但是多数情况下,用户需要定制自己的windows镜像。本文提供完整的镜像制作过程。

    制作环境 unbuntu 14.04 server 

    在使用kvm命令建立虚拟机时每次都要输入很长的命令,容易出现输入错误,可以使用libvirt管理虚拟机,libvirt支持kvm,xen等主流虚拟机的管理,安装:

    apt-get install qemu-kvm libvirt-bin virtinst

    下载virtio驱动,因为win默认不支持virtio驱动,而通过openstack管理虚拟机是需要virtio驱动的。需要两个virtio驱动,一个是硬盘的,一个是网卡的,即:virtio-win-0.1-30.iso和virtio-win-1.1.16.vfd

    wget 'http://autosetup1.googlecode.com/files/virtio-win-1.1.16.vfd'
    wget 'http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/virtio-win-0.1-30.iso'

     我在安装的时候,第一个链接是可以正常使用,但是第二个是报错404.所以我在另外的地方找到了一个比较新的版本 https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.105-1/ 注意选择上面对应的两个版本

     下载了一个win7的官方纯净版镜像 win7.iso 将三个文件放到ubuntu下的同一个子目录下,/home/house/ 下

    建立一个硬盘映射,用来存放我们将来生成的镜像文件

    qemu-img create -f qcow2 windows7.qcow2 15G

    输出: Formatting 'windows7.qcow2', fmt=qcow2 size=21474836480 encryption=off cluster_size=65536 lazy_refcounts=off

    这时候你就能够在刚才的目录下看到这个文件了,下面创建镜像

    virt-install --connect qemu:///system 
      --name windows7 --ram 2048 --vcpus 2 
      --network network=default,model=virtio 
      --disk path=windows7.qcow2,format=qcow2,device=disk,bus=virtio 
      --cdrom /home/house/win7.iso 
      --disk path=/home/house/virtio-win-0.1.105.iso,device=cdrom 
      --vnc 10.74.116.31:8 --os-type windows --os-variant win7

    输出: Starting install...
    Creating domain... | 0 B 00:00
    Cannot open display:
    Run 'virt-viewer --help' to see a full list of available command line options
    Domain installation still in progress. Waiting for installation to complete.

    我们没有安装图形界面,所以无法进行手动安装,安装了图形界面的,直接使用virt-viewer进行操作,所以我们使用另外一个工具spice进行远程安装。http://www.spice-space.org/download.html

    在上面的命令中,我们需要将--vnc替换为--graphics spice,listen=0.0.0.0即

    virt-install --connect qemu:///system 
      --name windows7 --ram 2048 --vcpus 2 
      --network network=default,model=virtio 
      --disk path=windows7.qcow2,format=qcow2,device=disk,bus=virtio 
      --cdrom /home/zhangjun/win7.iso 
      --disk path=/home/zhangjun/virtio-win-0.1.105.iso,device=cdrom 
       --os-type windows --os-variant win7 --graphics spice,listen=0.0.0.0

    打开spice 在connection address处输入你安装机器的ip地址:spice://192.168.1.2:5900(端口号默认5900,若有其他安装程序在,则自动+1)

    点击connec即可进入安装界面 ,在驱动选择界面 点击加载驱动程序->浏览->驱动器virtio-win-0.1.1 

    可以看到RadHat virtIO SCSI 磁盘驱动。选择,进入系统后在类似目录下安装网卡驱动。

    note:安装过程中也许会出现一些问题,推荐一些virt命令,来查看虚拟机状态

    virsh -c qemu:///system list//查看虚拟机
    virsh shutdown windows7 //关闭
    virsh destroy windows7 //删除
    virsh undefine windows7 //取消domin

    这时候就大功告成了,我们成功的制作了一个qcow2的镜像。接下来部署到glance上去

    glance image-create --name "windows7" --file home/house/windows7.qcow2 --disk-format qcow2 --container-format bare --is-public True --progress

    成功以后就可以在dashboard上看到这个虚拟机了。创建成功以后,注意需要给其所在的安全组添加规则 TCP 端口3389,关闭防火墙,开启远程桌面连接,即可ping通与远程连接上了。

  • 相关阅读:
    maven报错【Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of】
    Srping框架中使用@query注解实现复杂查询
    FreeMarker自定义TemplateDirectiveModel
    SpringMVC和Freemarker整合,带自定义标签的使用方法
    关于FreeMarker自定义TemplateDirectiveModel
    滑块验证码【插件待研究】
    注册页面 注册码【欠缺较多 待完善】
    IO流-文件的写入和读取
    Date、String、Calendar相互转化
    Runtime类
  • 原文地址:https://www.cnblogs.com/SnowStark/p/4666787.html
Copyright © 2011-2022 走看看