Chapter 2. Creating RHEL KVM or RHOSP-compatible images
To create images that you can manage in the Red Hat OpenStack Platform (RHOSP) Image service (glance), you can use Red Hat Enterprise Linux (RHEL) Kernel-based Virtual Machine (KVM) instance images, or you can manually create RHOSP-compatible images in the QCOW2 format by using RHEL ISO files or Windows ISO files.
2.1. Creating RHEL KVM images
Use Red Hat Enterprise Linux (RHEL) Kernel-based Virtual Machine (KVM) instance images to create images that you can manage in the Red Hat OpenStack Platform (RHOSP) Image service (glance).
2.1.1. Using a RHEL KVM instance image with Red Hat OpenStack Platform
You can use one of the following Red Hat Enterprise Linux (RHEL) Kernel-based Virtual Machine (KVM) instance images with Red Hat OpenStack Platform (RHOSP):
These QCOW2 images are configured with cloud-init
and must have EC2-compatible metadata services for provisioning Secure Shell (SSH) keys to function correctly.
Ready Windows KVM instance images in QCOW2 format are not available.
For KVM instance images:
-
The
root
account in the image is deactivated, butsudo
access is granted to a special user namedcloud-user
. -
There is no
root
password set for this image.
The root
password is locked in /etc/shadow
by placing !!
in the second field.
For a RHOSP instance, generate an SSH keypair from the RHOSP dashboard or command line, and use that key combination to perform an SSH public authentication to the instance as root user.
When you launch the instance, this public key is injected to it. You can then authenticate by using the private key that you download when you create the keypair.
2.1.2. Creating a RHEL-based root partition image for bare-metal instances
To create a custom root partition image for bare-metal instances, download the base Red Hat Enterprise Linux KVM instance image, and then upload the image to the Image service (glance).
Procedure
- Download the base Red Hat Enterprise Linux KVM instance image from the Customer Portal.
Define
DIB_LOCAL_IMAGE
as the downloaded image:Copy to Clipboard Copied! Toggle word wrap Toggle overflow export DIB_LOCAL_IMAGE=rhel-<ver>-x86_64-kvm.qcow2
$ export DIB_LOCAL_IMAGE=rhel-<ver>-x86_64-kvm.qcow2
-
Replace
<ver>
with the RHEL version number of the image.
-
Replace
Set your registration information depending on your method of registration:
Red Hat Customer Portal:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export REG_USER='<username>' export REG_PASSWORD='<password>' export REG_AUTO_ATTACH=true export REG_METHOD=portal export https_proxy='<IP_address:port>' (if applicable) export http_proxy='<IP_address:port>' (if applicable)
$ export REG_USER='<username>' $ export REG_PASSWORD='<password>' $ export REG_AUTO_ATTACH=true $ export REG_METHOD=portal $ export https_proxy='<IP_address:port>' (if applicable) $ export http_proxy='<IP_address:port>' (if applicable)
Red Hat Satellite:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export REG_USER='<username>' export REG_PASSWORD='<password>' export REG_SAT_URL='<satellite-url>' export REG_ORG='<satellite-org>' export REG_ENV='<satellite-env>' export REG_METHOD=<method>
$ export REG_USER='<username>' $ export REG_PASSWORD='<password>' $ export REG_SAT_URL='<satellite-url>' $ export REG_ORG='<satellite-org>' $ export REG_ENV='<satellite-env>' $ export REG_METHOD=<method>
-
Replace values in angle brackets
<>
with the correct values for your Red Hat Customer Portal or Red Hat Satellite registration.
Optional: If you have any offline repositories, you can define
DIB_YUM_REPO_CONF
as a local repository configuration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow export DIB_YUM_REPO_CONF=<file-path>
$ export DIB_YUM_REPO_CONF=<file-path>
-
Replace
<file-path>
with the path to your local repository configuration file.
-
Replace
Use the
diskimage-builder
tool to extract the kernel asrhel-image.vmlinuz
and the initial RAM disk asrhel-image.initrd
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow export DIB_RELEASE=<ver> disk-image-create rhel baremetal \ -o rhel-image
$ export DIB_RELEASE=<ver> $ disk-image-create rhel baremetal \ -o rhel-image
Upload the images to the Image service:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow KERNEL_ID=$(openstack image create \ --file rhel-image.vmlinuz --public \ --container-format aki --disk-format aki \ -f value -c id rhel-image.vmlinuz) RAMDISK_ID=$(openstack image create \ --file rhel-image.initrd --public \ --container-format ari --disk-format ari \ -f value -c id rhel-image.initrd) openstack image create \ --file rhel-image.qcow2 --public \ --container-format bare \ --disk-format qcow2 \ --property kernel_id=$KERNEL_ID \ --property ramdisk_id=$RAMDISK_ID \ rhel-root-partition-bare-metal-image
$ KERNEL_ID=$(openstack image create \ --file rhel-image.vmlinuz --public \ --container-format aki --disk-format aki \ -f value -c id rhel-image.vmlinuz) $ RAMDISK_ID=$(openstack image create \ --file rhel-image.initrd --public \ --container-format ari --disk-format ari \ -f value -c id rhel-image.initrd) $ openstack image create \ --file rhel-image.qcow2 --public \ --container-format bare \ --disk-format qcow2 \ --property kernel_id=$KERNEL_ID \ --property ramdisk_id=$RAMDISK_ID \ rhel-root-partition-bare-metal-image
2.1.3. Creating a RHEL-based whole-disk user image for bare-metal instances
To create a whole-disk user image for bare-metal instances, download the base Red Hat Enterprise Linux KVM instance image, and then upload the image to the Image service (glance).
Procedure
- Download the base Red Hat Enterprise Linux KVM instance image from the Customer Portal.
Define
DIB_LOCAL_IMAGE
as the downloaded image:Copy to Clipboard Copied! Toggle word wrap Toggle overflow export DIB_LOCAL_IMAGE=rhel-<ver>-x86_64-kvm.qcow2
$ export DIB_LOCAL_IMAGE=rhel-<ver>-x86_64-kvm.qcow2
-
Replace
<ver>
with the RHEL version number of the image.
-
Replace
Set your registration information depending on your method of registration:
Red Hat Customer Portal:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export REG_USER='<username>' export REG_PASSWORD='<password>' export REG_AUTO_ATTACH=true export REG_METHOD=portal export https_proxy='<IP_address:port>' (if applicable) export http_proxy='<IP_address:port>' (if applicable)
$ export REG_USER='<username>' $ export REG_PASSWORD='<password>' $ export REG_AUTO_ATTACH=true $ export REG_METHOD=portal $ export https_proxy='<IP_address:port>' (if applicable) $ export http_proxy='<IP_address:port>' (if applicable)
Red Hat Satellite:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow export REG_USER='<username>' export REG_PASSWORD='<password>' export REG_SAT_URL='<satellite-url>' export REG_ORG='<satellite-org>' export REG_ENV='<satellite-env>' export REG_METHOD=<method>
$ export REG_USER='<username>' $ export REG_PASSWORD='<password>' $ export REG_SAT_URL='<satellite-url>' $ export REG_ORG='<satellite-org>' $ export REG_ENV='<satellite-env>' $ export REG_METHOD=<method>
-
Replace values in angle brackets
<>
with the correct values for your Red Hat Customer Portal or Red Hat Satellite registration.
Optional: If you have any offline repositories, you can define
DIB_YUM_REPO_CONF
as a local repository configuration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow export DIB_YUM_REPO_CONF=<file-path>
$ export DIB_YUM_REPO_CONF=<file-path>
-
Replace
<file-path>
with the path to your local repository configuration file.
-
Replace
Upload the image to the Image service:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow openstack image create \ --file rhel-image.qcow2 --public \ --container-format bare \ --disk-format qcow2 \ rhel-whole-disk-bare-metal-image
$ openstack image create \ --file rhel-image.qcow2 --public \ --container-format bare \ --disk-format qcow2 \ rhel-whole-disk-bare-metal-image
2.2. Creating instance images with RHEL or Windows ISO files
You can create custom Red Hat Enterprise Linux (RHEL) or Windows images in QCOW2 format from ISO files, and upload these images to the Red Hat OpenStack Platform (RHOSP) Image service (glance) for use when creating instances.
2.2.1. Prerequisites
- A Linux host machine to create an image. This can be any machine on which you can install and run the Linux packages, except for the undercloud or the overcloud.
The
advanced-virt
repository is enabled:Copy to Clipboard Copied! Toggle word wrap Toggle overflow sudo subscription-manager repos --enable=advanced-virt-for-rhel-<ver>-x86_64-rpms
$ sudo subscription-manager repos --enable=advanced-virt-for-rhel-<ver>-x86_64-rpms
The
virt-manager
application is installed to have all packages necessary to create a guest operating system:Copy to Clipboard Copied! Toggle word wrap Toggle overflow sudo dnf module install -y virt
$ sudo dnf module install -y virt
The
libguestfs-tools
package is installed to have a set of tools to access and modify virtual machine images:Copy to Clipboard Copied! Toggle word wrap Toggle overflow sudo dnf install -y libguestfs-tools-c
$ sudo dnf install -y libguestfs-tools-c
- A RHEL 9 or 8 ISO file or a Windows ISO file. For more information about RHEL ISO files, see RHEL 9.0 Binary DVD or RHEL 8.6 Binary DVD. If you do not have a Windows ISO file, see the Microsoft Evaluation Center to download an evaluation image.
-
A text editor, if you want to change the
kickstart
files (RHEL only).
If you install the libguestfs-tools
package on the undercloud, deactivate iscsid.socket
to avoid port conflicts with the tripleo_iscsid
service on the undercloud:
sudo systemctl disable --now iscsid.socket
$ sudo systemctl disable --now iscsid.socket
When you have the prerequisites in place, you can proceed to create a RHEL or Windows image:
2.2.2. Creating a Red Hat Enterprise Linux 9 image
You can create a Red Hat OpenStack Platform (RHOSP) image in QCOW2 format by using a Red Hat Enterprise Linux (RHEL) 9 ISO file.
Procedure
-
Log on to your host machine as the
root
user. Start the installation by using
virt-install
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow virt-install \ --virt-type kvm \ --name <rhel9-cloud-image> \ --ram <2048> \ --cdrom </var/lib/libvirt/images/rhel-9.0-x86_64-dvd.iso> \ --disk <rhel9.qcow2>,format=qcow2,size=<10> \ --network=bridge:virbr0 \ --graphics vnc,listen=127.0.0.1 \ --noautoconsole \ --os-variant=<rhel9.0>
[root@host]# virt-install \ --virt-type kvm \ --name <rhel9-cloud-image> \ --ram <2048> \ --cdrom </var/lib/libvirt/images/rhel-9.0-x86_64-dvd.iso> \ --disk <rhel9.qcow2>,format=qcow2,size=<10> \ --network=bridge:virbr0 \ --graphics vnc,listen=127.0.0.1 \ --noautoconsole \ --os-variant=<rhel9.0>
Replace the values in angle brackets
<>
with the correct values for your RHEL 9 image.This command launches an instance and starts the installation process.
NoteIf the instance does not launch automatically, run the
virt-viewer
command to view the console:Copy to Clipboard Copied! Toggle word wrap Toggle overflow virt-viewer <rhel9-cloud-image>
[root@host]# virt-viewer <rhel9-cloud-image>
Configure the instance:
- At the initial Installer boot menu, select Install Red Hat Enterprise Linux 9.
- Choose the appropriate Language and Keyboard options.
- When prompted about which type of devices your installation uses, select Auto-detected installation media.
- When prompted about which type of installation destination, select Local Standard Disks. For other storage options, select Automatically configure partitioning.
- In the Which type of installation would you like? window, choose the Basic Server install, which installs an SSH server.
- For network and host name, select eth0 for network and choose a host name for your device. The default host name is localhost.localdomain.
- Enter a password in the Root Password field and enter the same password again in the Confirm field.
- When the on-screen message confirms that the installation is complete, reboot the instance and log in as the root user.
Update the
/etc/sysconfig/network-scripts/ifcfg-eth0
file so that it contains only the following values:Copy to Clipboard Copied! Toggle word wrap Toggle overflow TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=no
TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=no
- Reboot the machine.
Register the machine with the Content Delivery Network.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow sudo subscription-manager register sudo subscription-manager attach \ --pool=<pool-id> sudo subscription-manager repos \ --enable rhel-9-for-x86_64-baseos-rpms \ --enable rhel-9-for-x86_64-appstream-rpms
# sudo subscription-manager register # sudo subscription-manager attach \ --pool=<pool-id> # sudo subscription-manager repos \ --enable rhel-9-for-x86_64-baseos-rpms \ --enable rhel-9-for-x86_64-appstream-rpms
-
Replace
pool-id
with a valid pool ID. You can see a list of available pool IDs by running thesubscription-manager list --available
command.
-
Replace
Update the system:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow dnf -y update
# dnf -y update
Install the
cloud-init
packages:Copy to Clipboard Copied! Toggle word wrap Toggle overflow dnf install -y cloud-utils-growpart cloud-init
# dnf install -y cloud-utils-growpart cloud-init
Edit the
/etc/cloud/cloud.cfg
configuration file and add the following content undercloud_init_modules
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - resolv-conf
- resolv-conf
The
resolv-conf
option automatically configures theresolv.conf
file when an instance boots for the first time. This file contains information related to the instance such asnameservers
,domain
, and other options.Add the following line to
/etc/sysconfig/network
to avoid issues when accessing the EC2 metadata service:Copy to Clipboard Copied! Toggle word wrap Toggle overflow NOZEROCONF=yes
NOZEROCONF=yes
To ensure that the console messages appear in the Log tab on the dashboard and the
nova console-log
output, add the following boot option to the/etc/default/grub
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
Run the
grub2-mkconfig
command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow grub2-mkconfig -o /boot/grub2/grub.cfg
# grub2-mkconfig -o /boot/grub2/grub.cfg
The output is as follows:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-229.9.2.el9.x86_64 Found initrd image: /boot/initramfs-3.10.0-229.9.2.el9.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-121.el9.x86_64 Found initrd image: /boot/initramfs-3.10.0-121.el9.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-b82a3044fb384a3f9aeacf883474428b Found initrd image: /boot/initramfs-0-rescue-b82a3044fb384a3f9aeacf883474428b.img done
Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-229.9.2.el9.x86_64 Found initrd image: /boot/initramfs-3.10.0-229.9.2.el9.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-121.el9.x86_64 Found initrd image: /boot/initramfs-3.10.0-121.el9.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-b82a3044fb384a3f9aeacf883474428b Found initrd image: /boot/initramfs-0-rescue-b82a3044fb384a3f9aeacf883474428b.img done
Deregister the instance so that the resulting image does not contain the subscription details for this instance:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow subscription-manager repos --disable=* subscription-manager unregister dnf clean all
# subscription-manager repos --disable=* # subscription-manager unregister # dnf clean all
Power off the instance:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow poweroff
# poweroff
Reset and clean the image by using the
virt-sysprep
command so that it can be used to create instances without issues:Copy to Clipboard Copied! Toggle word wrap Toggle overflow virt-sysprep -d <rhel9-cloud-image>
[root@host]# virt-sysprep -d <rhel9-cloud-image>
Reduce the image size by converting any free space in the disk image back to free space in the host:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow virt-sparsify \ --compress <rhel9.qcow2> <rhel9-cloud.qcow2>
[root@host]# virt-sparsify \ --compress <rhel9.qcow2> <rhel9-cloud.qcow2>
This command creates a new
<rhel9-cloud.qcow2>
file in the location from where the command is run.NoteYou must manually resize the partitions of instances based on the image in accordance with the disk space in the flavor that is applied to the instance.
The <rhel9-cloud.qcow2>
image file is ready to be uploaded to the Image service. For more information about uploading this image to your RHOSP deployment, see Uploading images to the Image service.
2.2.3. Creating a Red Hat Enterprise Linux 8 image
You can create a Red Hat OpenStack Platform (RHOSP) image in QCOW2 format by using a Red Hat Enterprise Linux (RHEL) 8 ISO file.
Procedure
-
Log on to your host machine as the
root
user. Start the installation by using
virt-install
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow virt-install \ --virt-type kvm \ --name <rhel86-cloud-image> \ --ram <2048> \ --vcpus <2> \ --disk <rhel86.qcow2>,format=qcow2,size=<10> \ --location <rhel-8.6-x86_64-boot.iso> \ --network=bridge:virbr0 \ --graphics vnc,listen=127.0.0.1 \ --noautoconsole \ --os-variant <rhel8.6>
[root@host]# virt-install \ --virt-type kvm \ --name <rhel86-cloud-image> \ --ram <2048> \ --vcpus <2> \ --disk <rhel86.qcow2>,format=qcow2,size=<10> \ --location <rhel-8.6-x86_64-boot.iso> \ --network=bridge:virbr0 \ --graphics vnc,listen=127.0.0.1 \ --noautoconsole \ --os-variant <rhel8.6>
Replace the values in angle brackets
<>
with the correct values for your RHEL image.This command launches an instance and starts the installation process.
NoteIf the instance does not launch automatically, run the
virt-viewer
command to view the console:Copy to Clipboard Copied! Toggle word wrap Toggle overflow virt-viewer <rhel86-cloud-image>
[root@host]# virt-viewer <rhel86-cloud-image>
Configure the instance:
- At the initial Installer boot menu, select Install Red Hat Enterprise Linux 8.
- Choose the appropriate Language and Keyboard options.
- When prompted about which type of devices your installation uses, select Basic Storage Devices.
-
Choose a host name for your device. The default host name is
localhost.localdomain
. -
Set the timezone and
root
password. - In the Which type of installation would you like? window, choose the Basic Server install, which installs an SSH server.
- When the on-screen message confirms that the installation is complete, reboot the instance and log in as the root user.
Update the
/etc/sysconfig/network-scripts/ifcfg-eth0
file so that it contains only the following values:Copy to Clipboard Copied! Toggle word wrap Toggle overflow TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=no
TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=no
- Reboot the machine.
Register the machine with the Content Delivery Network:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow sudo subscription-manager register sudo subscription-manager attach \ --pool=<pool-id> sudo subscription-manager repos \ --enable rhel-8-for-x86_64-baseos-rpms \ --enable rhel-8-for-x86_64-appstream-rpms
# sudo subscription-manager register # sudo subscription-manager attach \ --pool=<pool-id> # sudo subscription-manager repos \ --enable rhel-8-for-x86_64-baseos-rpms \ --enable rhel-8-for-x86_64-appstream-rpms
-
Replace
pool-id
with a valid pool ID. You can see a list of available pool IDs by running thesubscription-manager list --available
command.
-
Replace
Update the system:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow dnf -y update
# dnf -y update
Install the
cloud-init
packages:Copy to Clipboard Copied! Toggle word wrap Toggle overflow dnf install -y cloud-utils-growpart cloud-init
# dnf install -y cloud-utils-growpart cloud-init
Edit the
/etc/cloud/cloud.cfg
configuration file and add the following content undercloud_init_modules
.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - resolv-conf
- resolv-conf
The
resolv-conf
option automatically configures theresolv.conf
file when an instance boots for the first time. This file contains information related to the instance such asnameservers
,domain
, and other options.To prevent network issues, create
/etc/udev/rules.d/75-persistent-net-generator.rules
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow echo "#" > /etc/udev/rules.d/75-persistent-net-generator.rules
# echo "#" > /etc/udev/rules.d/75-persistent-net-generator.rules
This prevents the
/etc/udev/rules.d/70-persistent-net.rules
file from being created. If the/etc/udev/rules.d/70-persistent-net.rules
file is created, networking might not function correctly when you boot from snapshots because the network interface is created aseth1
instead ofeth0
and the IP address is not assigned.Add the following line to
/etc/sysconfig/network
to avoid issues when accessing the EC2 metadata service:Copy to Clipboard Copied! Toggle word wrap Toggle overflow NOZEROCONF=yes
NOZEROCONF=yes
To ensure that the console messages appear in the Log tab on the dashboard and the
nova console-log
output, add the following boot option to the/etc/grub.conf
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
Deregister the instance so that the resulting image does not contain the same subscription details for this instance:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow subscription-manager repos --disable=* subscription-manager unregister dnf clean all
# subscription-manager repos --disable=* # subscription-manager unregister # dnf clean all
Power off the instance:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow poweroff
# poweroff
Reset and clean the image by using the
virt-sysprep
command so that it can be used to create instances without issues:Copy to Clipboard Copied! Toggle word wrap Toggle overflow virt-sysprep -d <rhel86-cloud-image>
[root@host]# virt-sysprep -d <rhel86-cloud-image>
Reduce the image size by converting any free space in the disk image back to free space in the host:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow virt-sparsify \ --compress <rhel86.qcow2> <rhel86-cloud.qcow2>
[root@host]# virt-sparsify \ --compress <rhel86.qcow2> <rhel86-cloud.qcow2>
This command creates a new
<rhel86-cloud.qcow2>
file in the location from where the command is run.NoteYou must manually resize the partitions of instances based on the image in accordance with the disk space in the flavor that is applied to the instance.
The <rhel86-cloud.qcow2>
image file is ready to be uploaded to the Image service. For more information about uploading this image to your RHOSP deployment, see Uploading images to the Image service.
2.2.4. Creating a Windows image
You can create a Red Hat OpenStack Platform (RHOSP) image in QCOW2 format by using a Windows ISO file.
Procedure
-
Log on to your host machine as the
root
user. Start the installation by using
virt-install
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow virt-install \ --name=<windows-image> \ --disk size=<size> \ --cdrom=<file-path-to-windows-iso-file> \ --os-type=windows \ --network=bridge:virbr0 \ --graphics spice \ --ram=<ram>
[root@host]# virt-install \ --name=<windows-image> \ --disk size=<size> \ --cdrom=<file-path-to-windows-iso-file> \ --os-type=windows \ --network=bridge:virbr0 \ --graphics spice \ --ram=<ram>
Replace the values in angle brackets
<>
withe the correct values for your Windows image.NoteThe
--os-type=windows
parameter ensures that the clock is configured correctly for the Windows instance and enables its Hyper-V enlightenment features. You must also setos_type=windows
in the image metadata before uploading the image to the Image service (glance).
The
virt-install
command saves the instance image as/var/lib/libvirt/images/<windows-image>.qcow2
by default. If you want to keep the instance image elsewhere, change the parameter of the--disk
option:Copy to Clipboard Copied! Toggle word wrap Toggle overflow --disk path=<file-name>,size=<size>
--disk path=<file-name>,size=<size>
Replace
<file-name>
with the name of the file that stores the instance image, and optionally its path. For example,path=win8.qcow2,size=8
creates an 8 GB file namedwin8.qcow2
in the current working directory.NoteIf the instance does not launch automatically, run the
virt-viewer
command to view the console:Copy to Clipboard Copied! Toggle word wrap Toggle overflow virt-viewer <windows-image>
[root@host]# virt-viewer <windows-image>
For more information about how to install Windows, see the Microsoft documentation.
- To allow the newly-installed Windows system to use the virtualized hardware, you might need to install VirtIO drivers. For more information, see Installing KVM paravirtualized drivers for Windows virtual machines in Configuring and managing virtualization.
To complete the configuration, download and run Cloudbase-Init on the Windows system. At the end of the installation of Cloudbase-Init, select the Run Sysprep and Shutdown checkboxes. The
Sysprep
tool makes the instance unique by generating an OS ID, which is used by certain Microsoft services.ImportantRed Hat does not provide technical support for Cloudbase-Init. If you encounter an issue, see Contact Cloudbase Solutions.
When the Windows system shuts down, the
<windows-image.qcow2>
image file is ready to be uploaded to the Image service. For more information about uploading this image to your RHOSP deployment, see Uploading images to the Image service.
2.3. Creating an image for UEFI Secure Boot
When the overcloud contains UEFI Secure Boot Compute nodes, you can create a Secure Boot instance image that cloud users can use to launch Secure Boot instances.
Procedure
Create a new image for UEFI Secure Boot:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow openstack image create --file <base_image_file> uefi_secure_boot_image
$ openstack image create --file <base_image_file> uefi_secure_boot_image
-
Replace
<base_image_file>
with an image file that supports UEFI and the GUID Partition Table (GPT) standard, and includes an EFI system partition.
-
Replace
If the default machine type is not
q35
, then set the machine type toq35
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow openstack image set --property hw_machine_type=q35 uefi_secure_boot_image
$ openstack image set --property hw_machine_type=q35 uefi_secure_boot_image
Specify that the instance must be scheduled on a UEFI Secure Boot host:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow openstack image set \ --property hw_firmware_type=uefi \ --property os_secure_boot=required \ uefi_secure_boot_image
$ openstack image set \ --property hw_firmware_type=uefi \ --property os_secure_boot=required \ uefi_secure_boot_image
2.4. Metadata properties for virtual hardware
The Compute service (nova) has deprecated support for using libosinfo
data to set default device models. Instead, use the following image metadata properties to configure the optimal virtual hardware for an instance:
-
os_distro
-
os_version
-
hw_cdrom_bus
-
hw_disk_bus
-
hw_scsi_model
-
hw_vif_model
-
hw_video_model
-
hypervisor_type
For more information about these metadata properties, see Image configuration parameters.