一、软件包下载地址

系统ISO镜像下载地址:​​https://msdn.itellyou.cn/​

virtio驱动下载地址:​​https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.171-1/virtio-win-0.1.171.iso​

CloudbaseInitSetup下载地址:​https://cloudbase.it/downloads/CloudbaseInitSetup_0_9_11_x64.msi

二、安装系统

2.1、创建系统镜像

[root@openstack-image ~]#qemu-img create -f qcow2 /var/lib/libvirt/images/Win2008-R2-Enterprise.qcow2 20G
Formatting '/var/lib/libvirt/images/Win2008-R2-Enterprise.qcow2', fmt=qcow2 size=21474836480 encryption=off cluster_size=65536 lazy_refcounts=off
[root@openstack-image ~]#ll /var/lib/libvirt/images/
total 6.2G
-rw-r--r-- 1 root root 1.7G Jan 20 21:47 CentOS-7.9-x86_64.qcow2
-rw-r--r-- 1 root root 1.3G Jan 23 15:50 CentOS-7-x86_64-GenericCloud-1511.qcow2
-rw-r--r-- 1 root root 3.3G Jan 22 19:36 Ubuntu-18.04-x86_64.qcow2
-rw-r--r-- 1 root root 193K Jan 26 15:57 Win2008-R2-Enterprise.qcow2

2.2、上传Windows镜像

[root@openstack-image ~]#ll /usr/local/src/
total 5.1G
-rw-r--r-- 1 qemu qemu 973M Jan 20 16:19 CentOS-7-x86_64-Minimal-2009.iso
-rw-r--r-- 1 root root 3.2G Jan 23 16:59 cn_windows_server_2008_r2_standard_enterprise_datacenter_and_web_with_sp1_vl_build_x64_dvd_617396.iso
-rw-r--r-- 1 qemu qemu 951M Jan 20 21:35 ubuntu-18.04.5-server-amd64.iso

2.3、下载virtio驱动

[root@openstack-image ~]#wget -O /usr/local/src/virtio-win-0.1.171.iso https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.171-1/virtio-win-0.1.171.iso
[root@openstack-image ~]#ll /usr/local/src/
total 5.4G
-rw-r--r-- 1 qemu qemu 973M Jan 20 16:19 CentOS-7-x86_64-Minimal-2009.iso
-rw-r--r-- 1 qemu qemu 3.2G Jan 23 16:59 cn_windows_server_2008_r2_standard_enterprise_datacenter_and_web_with_sp1_vl_build_x64_dvd_617396.iso
-rw-r--r-- 1 qemu qemu 951M Jan 20 21:35 ubuntu-18.04.5-server-amd64.iso
-rw-r--r-- 1 qemu qemu 355M Jan 26 11:31 virtio-win-0.1.171.iso

2.4、下载CloudbaseInitSetup

将下载的CloudbaseInitSetup_0_9_11_x64.msi这个文件打包成CloudbaseInitSetup_0_9_11_x64.iso文件;可以借助windows下的第三方软件UltraISO打包

[root@openstack-image ~]#ll /usr/local/src/
total 5.5G
-rw-r--r-- 1 qemu qemu 973M Jan 20 16:19 CentOS-7-x86_64-Minimal-2009.iso
-rw-r--r-- 1 root root 40M Jan 26 16:08 CloudbaseInitSetup_0_9_11_x64.iso
-rw-r--r-- 1 qemu qemu 3.2G Jan 23 16:59 cn_windows_server_2008_r2_standard_enterprise_datacenter_and_web_with_sp1_vl_build_x64_dvd_617396.iso
-rw-r--r-- 1 qemu qemu 951M Jan 20 21:35 ubuntu-18.04.5-server-amd64.iso
-rw-r--r-- 1 qemu qemu 355M Jan 26 11:31 virtio-win-0.1.171.iso

2.5、使用命令安装Windows2008

[root@openstack-image ~]#virt-install --name=WinSer2008-R2-Enterprise-x86_64 --ram=1024 --cpu=host --vcpus=1 \
> --os-type=windows --os-variant=win2k8 \
> --disk /var/lib/libvirt/images/Win2008-R2-Enterprise.qcow2,bus=virtio \
> --disk /usr/local/src/cn_windows_server_2008_r2_standard_enterprise_datacenter_and_web_with_sp1_vl_build_x64_dvd_617396.iso,device=cdrom,bus=ide \
> --disk /usr/local/src/virtio-win-0.1.171.iso,device=cdrom,bus=ide \
> --disk /usr/local/src/CloudbaseInitSetup_0_9_11_x64.iso,device=cdrom,bus=ide \
> --network bridge=br0,model=virtio \
> --graphics vnc,listen=0.0.0.0 --noautoconsole

Starting install...
Domain installation still in progress. You can reconnect to
the console to complete the installation process.

2.6、开始加载中

制作Windows Server 2008系统OpenStack云实例镜像_OpenStack

2.7、安装界面

制作Windows Server 2008系统OpenStack云实例镜像_KVM_02

2.8、开始安装

制作Windows Server 2008系统OpenStack云实例镜像_OpenStack_03

2.9、选择安装版本

制作Windows Server 2008系统OpenStack云实例镜像_KVM_04

2.10、加载磁盘驱动程序

制作Windows Server 2008系统OpenStack云实例镜像_KVM_05

制作Windows Server 2008系统OpenStack云实例镜像_KVM_06

制作Windows Server 2008系统OpenStack云实例镜像_OpenStack_07

制作Windows Server 2008系统OpenStack云实例镜像_KVM_08

2.11、创建分区

制作Windows Server 2008系统OpenStack云实例镜像_OpenStack_09

2.12、安装过程中

制作Windows Server 2008系统OpenStack云实例镜像_OpenStack_10

2.13、安装完成

首次登录提示必须更改MM

制作Windows Server 2008系统OpenStack云实例镜像_OpenStack_11

2.14、登录成功界面

制作Windows Server 2008系统OpenStack云实例镜像_KVM_12

2.15、安装网卡驱动

制作Windows Server 2008系统OpenStack云实例镜像_KVM_13

制作Windows Server 2008系统OpenStack云实例镜像_KVM_14

制作Windows Server 2008系统OpenStack云实例镜像_OpenStack_15

制作Windows Server 2008系统OpenStack云实例镜像_OpenStack_16

2.16、验证网络连通性

制作Windows Server 2008系统OpenStack云实例镜像_KVM_17

2.17、开启远程登录

制作Windows Server 2008系统OpenStack云实例镜像_OpenStack_18

2.18、关闭防火墙

制作Windows Server 2008系统OpenStack云实例镜像_OpenStack_19

2.19、激活系统

制作Windows Server 2008系统OpenStack云实例镜像_KVM_20

2.20、验证系统

制作Windows Server 2008系统OpenStack云实例镜像_KVM_21

2.21、安装配置Cloudbase

制作Windows Server 2008系统OpenStack云实例镜像_KVM_22

2.22、Cloudbase配置完成

制作Windows Server 2008系统OpenStack云实例镜像_OpenStack_23

制作Windows Server 2008系统OpenStack云实例镜像_KVM_24

2.23、压缩磁盘文件

[root@openstack-image ~]#virt-sparsify --compress /var/lib/libvirt/images/Win2008-R2-Enterprise.qcow2 /var/lib/libvirt/images/WinSer2008-R2-Enterprise.qcow2
[ 0.1] Create overlay file in /tmp to protect source disk
[ 0.1] Examine source disk
[ 4.2] Copy to destination and make sparse
[ 425.4] Sparsify operation completed with no errors.
virt-sparsify: Before deleting the old disk, carefully check that the
target disk boots and works correctly.
You have new mail in /var/spool/mail/root
[root@openstack-image ~]#ll /var/lib/libvirt/images/
total 17G
-rw-r--r-- 1 root root 1.7G Jan 20 21:47 CentOS-7.9-x86_64.qcow2
-rw-r--r-- 1 root root 1.3G Jan 23 15:50 CentOS-7-x86_64-GenericCloud-1511.qcow2
-rw-r--r-- 1 root root 3.3G Jan 22 19:36 Ubuntu-18.04-x86_64.qcow2
-rw-r--r-- 1 qemu qemu 7.2G Jan 26 16:48 Win2008-R2-Enterprise.qcow2
-rw-r--r-- 1 root root 3.3G Jan 26 16:57 WinSer2008-R2-Enterprise.qcow2

2.24、将磁盘镜像复制到控制节点

[root@openstack-image ~]#scp /var/lib/libvirt/images/WinSer2008-R2-Enterprise.qcow2 172.31.7.101:

2.25、OpenStack控制节点上传镜像

[root@openstack-controller1 ~]#openstack image create "WinSer-2008-R2-Enterprise-x86_64" --file /data/images/WinSer2008-R2-Enterprise.qcow2 --disk-format qcow2 --container-format bare --public
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum | b96db2946fdfd5a9aa93576e62c6c1ae |
| container_format | bare |
| created_at | 2022-01-26T07:01:45Z |
| disk_format | qcow2 |
| file | /v2/images/2d17bd10-2ea7-48ff-9fd1-32f44a73e07a/file |
| id | 2d17bd10-2ea7-48ff-9fd1-32f44a73e07a |
| min_disk | 0 |
| min_ram | 0 |
| name | WinSer-2008-R2-Enterprise-x86_64 |
| owner | 8bb16fc08c0147a3bb8aa3d78d91d4a1 |
| properties | os_hash_algo='sha512', os_hash_value='52ee4eb8ff8286e47bf22b5721f3efe81c3b44af47b9c9d40c120431e29e13027f83c61b73e92721778a24b8eb3fdec4ba07e92721f2b04a0e18fe2e0607b384', os_hidden='False' |
| protected | False |
| schema | /v2/schemas/image |
| size | 3501522944 |
| status | active |
| tags | |
| updated_at | 2022-01-26T07:02:12Z |
| virtual_size | None |
| visibility | public |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

2.26、验证镜像

[root@openstack-controller1 ~]#openstack image list
+--------------------------------------+----------------------------------+--------+
| ID | Name | Status |
+--------------------------------------+----------------------------------+--------+
| 5dc68c97-06e4-4b92-9417-dff4db8331d5 | CentOS-6.10 | active |
| 5854ab40-ef6a-41aa-b196-d059cfea563e | CentOS-7.2.1511 | active |
| 552fe061-0391-4f17-a4b9-45e54b900d3b | CentOS-7.2.1511-GenericCloud | active |
| 39b0c634-0075-454f-a4d6-0462eefda904 | CentOS-7.9.2009 | active |
| 12b3720a-a8e2-441e-8c57-9c796ae5c788 | Ubuntu-18.04 | active |
| e1a99ef7-f57f-4975-b8a0-dc2110c7c63c | Ubuntu-18.04-1 | active |
| 2d17bd10-2ea7-48ff-9fd1-32f44a73e07a | WinSer-2008-R2-Enterprise-x86_64 | active |
| 4816463a-99bd-40ae-88b3-cb5e71fd6831 | WinSer-2008-R2-x86_64 | active |
| 36faf2ba-f454-4f74-bbf5-789d341458cd | cirros-0.5.1 | active |
+--------------------------------------+----------------------------------+--------+