There are several techniques and tools available for creating cloud images.
I choose Virt Manager because of its rich feature set and easy-to-use interface,
Required Software: –
One Linux Machine
Virt manager
VirtIO drivers ISO
Windows ISO
Creating an Image :-
I am using a CentOS9.
The necessary virtio driver and Windows Server 2022 ISO were downloaded.
Using the following link, you can get the Virtio drivers: –
https://fedorapeople.org/groups/virt/virtio-win/direct-downloads
or
https://github.com/virtio-win/virtio-win-pkg-scripts/blob/master/README.md
Install the Virt Manager tool.
$ dnf -y install virt-manager
Upon installation. Launch the Virtua Machine Manager. Click on the Create a new VM button.

Select Local install media option >Forward.

Select the Browse option.

Select the Browse Local option.

Select Windows ISO and click on the Open option. (I have chosen The Windows Server 2022 ISO file.)

The operating system and version are automatically detected. Click on the Forward option.

Specify memory and CPUs (According to the OS minimum requirement, Windows Server 2022 requires 4GB. >Forward.

Specific the disk capacity (15 GB is sufficient for Windows).>Forward.

Select Customize configuration before install option > Click on Finish.

Select Disk bus, NIC Device model and Video VGA as VirtIO and apply.



Add Hardware> Select Storage > Device Type CDROM device, Click on Manager and select virtio drivers ISO >Finish.

Click on Begin Installation.

Click on Next.

Install Now.

Select according to your needs>Next.

Accept License terms > Next.

Choose Custom> press Enter.

Select the Load driver option.

Browse.

Expand virtio CD Drive.

Expand NetKVM folder.

Expand the OS folder based on your OS (I chose 2k22 because I’m installing the Windows 2022 server) > Select amd64 > click on OK.

Install network drivers. Click the Next option.


After installing the Network Drivers, browse and expand the virtio CD Drive and viostor folders. Expand the folder based on the version of Windows you are using. Select amd64 and then click OK.

To install storage drivers. Click the Install button.

You can see the disk after installing the storage driver. Click Next.

Installation began.

The final step is to complete the installation. It will ask for the administrator’s password. Enter the Windows administrator password and then click Finish.

You can enable or disable the firewall and other security features based on your needs.

Install the virtio guest utility by opening File Explorer and the virtio CD drive, then double-clicking the virtio-win-gt-x64 file.

Click on Next.

Accept License agreement > Click on Next.

Next.

Click on Install.

After the installation is complete, click Finish.

Shut down the virtual machine and remove the Windows Server and virtio driver ISOs.

To remove the CD-ROM, click the remove option. Remove CDROM 1 and 2.

After removing the CD-ROM. start the VM.

After turning on the VM. Open Disk Management. You can see the recovery partition. We must delete the Recovery partition; otherwise, the C disk will not expand to match the Openstack flavor disk size. (If you don’t see a recovery partition, you may disregard the partition deletion steps below.)

Delete the Recovery partition.
To delete the recovery partition. Open the command prompt as an administrator.
Enter diskpart. Press Enter.
Next, Enter the list command to list the disk and select the command to select the disk.
$ list disk
$ select disk 0
List partition in the disk
$ list partition
Select recovery partition
$ select partition 3
Delete recovery partition
$ delete partition override
The recovery partition was deleted successfully.


Optional –
To allow the Cloudbase-Init to run scripts during an instance boot, set the PowerShell execution
policy to be unrestricted:
C:\powershell
C:\Set-ExecutionPolicy Unrestricted
This is the final phase. Download and install the Windows cloud base-init package.
Download the cloud-init package.
URL – https://cloudbase.it/cloudbase-init/#download

Download Stable cloudbase-init x64.


After downloading the package, double-click the cloudbase-init file to install it.

Accept license agreement > Click on Next.

Next.

Select COM1 from the drop-down list >click on Next.

Click on Install.


Select the Run Sysprep and Shutdown option, then click Finish.


The virtual machine will shut down automatically. After turning off the VM, upload the Windows image to the Openstack cloud and use it.

The virt Manager VM’s default storage path is /var/lib/libvirt/images.

Ensure that you have already installed the OpenStack client tool. (Centos/RHEL – $ dnf install python3-openstackclient)
Download Openrc.sh to connect the CLI to your OpenStack cloud.

$ . openrc
Enter the Openstack User password.

Upload the image into the OpenStack Cloud.
$ Openstack create –public –disk-format qcow2 –container-format bare –file (file name) (Image name)


The image upload was completed successfully.


For testing the image. Create an instance with a Windows image.

I have selected a Medium flavor. The disk size is 60 GB. The C Disk will automatically be resized to 60 GB.

Once the Instance runs, it will ask to set up a new administrator password.

Enter the administrator password.


After signing in, you can see that the C drive is 60 GB. It will be automatically scaled according to the flavor.

The process of creating and testing images was successfully finished.
