用kvm-img创建一个10G大小的镜像文件:
kvm-img create -f qcow2 win2008.img 10G
因为windows没有默认的virtio驱动,所以先下载
wget http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/virtio-win-0.1-15.iso
wget http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/virtio-win-1.1.16.vfd
启动kvm,映射驱动vfd到软盘A
kvm -m 1024 -cdrom en_windows_server_2008_r2_dvd.iso -drive file=win2008.img,if=virtio,boot=on -fda virtio-win-1.1.16.vfd -boot d -nographic -vnc :1
用vnc访问安装,在安装的时候需要选择一下硬盘驱动,安装好以后,停掉虚拟机,重新用以下命令启动
kvm -m 1024 -drive file=win2008.img,if=virtio,boot=on -cdrom virtio-win-0.1-15.iso -net nic,model=virtio -net user -boot c -nographic -vnc :1
再用vnc访问,应该会提示自动安装好了virtio的网卡驱动
用glance添加这个镜像,指定格式为qcow2
glance add -A your_glance_token name="win2008" is_public=true disk_format=qcow2 < win2008.img
这样就完成了
原文地址:http://zhanguo1110.blog.51cto.com/5750817/1688235