目的
在 openstack 下创建 win7 镜像 (glance image)
创建镜像环境
需要 kvm 支持
需要利用 libvirtd 进行管理
系统软件需求
1. 支持 ks 部署的 pxe 环境 (略)
2. 安装软件 ( yum groupinstall "Virtualization Host" "Virtualization" )
3. 建议重启一下
4. 验证 libvirtd 环境 (systemctl status libvirtd) 没有启动则自己启动一下
5. 验证 virt 网络 (virsh net-list) (成功后会有 default 网络出现)
准备
创建磁盘
qemu-img create -f qcow2 /tmp/build_disk/win7_32.qcow2 40G
准备 iso
/tmp/win732.iso WIN7 镜像
/tmp/virtio-win-0.1.96.iso 驱动镜像
安装命令
注意, 把启动镜像放在 CDROM 前面, 驱动 ISO 放后面
virt-install --name=win7_32 --ram 4096 --vcpus=4 --disk path=/tmp/build_disk/win7_32.qcow2,format=qcow2,device=disk,bus=virtio --accelerate --network network=default,model=virtio --graphics vnc,listen=0.0.0.0 --noautoconsol --os-type=windows --disk device=cdrom,path=/tmp/win732.iso --disk device=cdrom,path=/tmp/virtio-win-0.1.96.iso --boot cdrom
安装过程需要调用 vncviewer 连接
vncview hostipaddress:5600
装载驱动
装载磁盘 virto 驱动, 注意红框路径 (64 位选择 amd64目录 替代 x86)
注意
安装过程中, windows 在完成分区, 导入安装信息后, 会自动关机
因此, 需要执行 virtsh start win7_32 重新启动该 vm 继续进行安装
后续问题
1. 启用 administrator 账号
2. 安装 qemu-ga.exe
3. 更新 balloon 驱动
4. 打开远程桌面
参考 qemu guest agent windows 安装
导入 win7 到 glance
参考命令
[root@hh-yun-puppet-129021 temp_terry(keystone_admin)]# uuidgen
fbf15035-1fee-404a-ad7b-e81a46d9d21f
[root@hh-yun-puppet-129021 temp_terry(keystone_admin)]# glance image-create --id fbf15035-1fee-404a-ad7b-e81a46d9d21f --name win7_32 --disk-format qcow2 --container-format bare --file ./win732.qcow2 --is-public true
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | 62a686b944d90fc26d7dee2682c602a3 |
| container_format | bare |
| created_at | 2017-11-14T10:19:09 |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | fbf15035-1fee-404a-ad7b-e81a46d9d21f |
| is_public | True |
| min_disk | 0 |
| min_ram | 0 |
| name | win7_32 |
| owner | bb0b51d166254dc99bc7462c0ac002ff |
| protected | False |
| size | 7303856128 |
| status | active |
| updated_at | 2017-11-14T10:20:28 |
| virtual_size | None |
+------------------+--------------------------------------+
参考命令, 修改 image 令其支持 qemu 属性
[root@hh-yun-puppet-129021 temp_terry(keystone_admin)]# glance image-update --property hw_qemu_guest_agent=yes fbf15035-1fee-404a-ad7b-e81a46d9d21f
+--------------------------------+--------------------------------------+
| Property | Value |
+--------------------------------+--------------------------------------+
| Property 'hw_qemu_guest_agent' | yes |
| checksum | 62a686b944d90fc26d7dee2682c602a3 |
| container_format | bare |
| created_at | 2017-11-14T10:19:09 |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | fbf15035-1fee-404a-ad7b-e81a46d9d21f |
| is_public | True |
| min_disk | 0 |
| min_ram | 0 |
| name | win7_32 |
| owner | bb0b51d166254dc99bc7462c0ac002ff |
| protected | False |
| size | 7303856128 |
| status | active |
| updated_at | 2017-11-14T10:22:29 |
| virtual_size | None |
+--------------------------------+--------------------------------------+
[root@hh-yun-puppet-129021 temp_terry(keystone_admin)]# glance image-update --property hw_vif_model=e1000 fbf15035-1fee-404a-ad7b-e81a46d9d21f
+--------------------------------+--------------------------------------+
| Property | Value |
+--------------------------------+--------------------------------------+
| Property 'hw_qemu_guest_agent' | yes |
| Property 'hw_vif_model' | e1000 |
| checksum | 62a686b944d90fc26d7dee2682c602a3 |
| container_format | bare |
| created_at | 2017-11-14T10:19:09 |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | fbf15035-1fee-404a-ad7b-e81a46d9d21f |
| is_public | True |
| min_disk | 0 |
| min_ram | 0 |
| name | win7_32 |
| owner | bb0b51d166254dc99bc7462c0ac002ff |
| protected | False |
| size | 7303856128 |
| status | active |
| updated_at | 2017-11-14T10:22:58 |
| virtual_size | None |
+--------------------------------+--------------------------------------+