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): Red Hat Enterprise Linux 9 KVM Guest Image Red Hat Enterprise Linux 8 KVM Guest Image 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. Note For KVM instance images: The root account in the image is deactivated, but sudo access is granted to a special user named cloud-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: Replace <ver> with the RHEL version number of the image. Set your registration information depending on your method of registration: Red Hat Customer Portal: Red Hat Satellite: 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: Replace <file-path> with the path to your local repository configuration file. Use the diskimage-builder tool to extract the kernel as rhel-image.vmlinuz and the initial RAM disk as rhel-image.initrd : Upload the images to the Image service: 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: Replace <ver> with the RHEL version number of the image. Set your registration information depending on your method of registration: Red Hat Customer Portal: Red Hat Satellite: 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: Replace <file-path> with the path to your local repository configuration file. Upload the image to the Image service: 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: The virt-manager application is installed to have all packages necessary to create a guest operating system: The libguestfs-tools package is installed to have a set of tools to access and modify virtual machine images: 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). Important 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: When you have the prerequisites in place, you can proceed to create a RHEL or Windows image: Create a Red Hat Enterprise Linux 9 image Create a Red Hat Enterprise Linux 8 image Create a 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 : 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. Note If the instance does not launch automatically, run the virt-viewer command to view the console: 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: Reboot the machine. Register the machine with the Content Delivery Network. Replace pool-id with a valid pool ID. You can see a list of available pool IDs by running the subscription-manager list --available command. Update the system: Install the cloud-init packages: Edit the /etc/cloud/cloud.cfg configuration file and add the following content under cloud_init_modules : The resolv-conf option automatically configures the resolv.conf file when an instance boots for the first time. This file contains information related to the instance such as nameservers , domain , and other options. Add the following line to /etc/sysconfig/network to avoid issues when accessing the EC2 metadata service: 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: Run the grub2-mkconfig command: The output is as follows: Deregister the instance so that the resulting image does not contain the subscription details for this instance: Power off the instance: Reset and clean the image by using the virt-sysprep command so that it can be used to create instances without issues: Reduce the image size by converting any free space in the disk image back to free space in the host: This command creates a new <rhel9-cloud.qcow2> file in the location from where the command is run. Note You 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 : Replace the values in angle brackets <> with the correct values for your RHEL image. This command launches an instance and starts the installation process. Note If the instance does not launch automatically, run the virt-viewer command to view the console: 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: Reboot the machine. Register the machine with the Content Delivery Network: Replace pool-id with a valid pool ID. You can see a list of available pool IDs by running the subscription-manager list --available command. Update the system: Install the cloud-init packages: Edit the /etc/cloud/cloud.cfg configuration file and add the following content under cloud_init_modules . The resolv-conf option automatically configures the resolv.conf file when an instance boots for the first time. This file contains information related to the instance such as nameservers , domain , and other options. To prevent network issues, create /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 as eth1 instead of eth0 and the IP address is not assigned. Add the following line to /etc/sysconfig/network to avoid issues when accessing the EC2 metadata service: 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: Deregister the instance so that the resulting image does not contain the same subscription details for this instance: Power off the instance: Reset and clean the image by using the virt-sysprep command so that it can be used to create instances without issues: Reduce the image size by converting any free space in the disk image back to free space in the host: This command creates a new <rhel86-cloud.qcow2> file in the location from where the command is run. Note You 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 : Replace the values in angle brackets <> withe the correct values for your Windows image. Note The --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 set os_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: 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 named win8.qcow2 in the current working directory. Note If the instance does not launch automatically, run the virt-viewer command to view the console: 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. Important Red 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: Replace <base_image_file> with an image file that supports UEFI and the GUID Partition Table (GPT) standard, and includes an EFI system partition. If the default machine type is not q35 , then set the machine type to q35 : Specify that the instance must be scheduled on a UEFI Secure Boot host: 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 .

Commands:
export DIB_LOCAL_IMAGE=rhel-<ver>-x86_64-kvm.qcow2
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_SAT_URL='<satellite-url>' export REG_ORG='<satellite-org>' export REG_ENV='<satellite-env>' export REG_METHOD=<method>
export DIB_YUM_REPO_CONF=<file-path>
export DIB_RELEASE=<ver> disk-image-create rhel baremetal -o rhel-image
KERNEL_ID=USD(openstack image create --file rhel-image.vmlinuz --public --container-format aki --disk-format aki -f value -c id rhel-image.vmlinuz) RAMDISK_ID=USD(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=USDKERNEL_ID --property ramdisk_id=USDRAMDISK_ID rhel-root-partition-bare-metal-image
export DIB_LOCAL_IMAGE=rhel-<ver>-x86_64-kvm.qcow2
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_SAT_URL='<satellite-url>' export REG_ORG='<satellite-org>' export REG_ENV='<satellite-env>' export REG_METHOD=<method>
export DIB_YUM_REPO_CONF=<file-path>
openstack image create --file rhel-image.qcow2 --public --container-format bare --disk-format qcow2 rhel-whole-disk-bare-metal-image
sudo subscription-manager repos --enable=advanced-virt-for-rhel-<ver>-x86_64-rpms
sudo dnf module install -y virt
sudo dnf install -y libguestfs-tools-c
sudo systemctl disable --now iscsid.socket
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>
virt-viewer <rhel9-cloud-image>
TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=no
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
dnf -y update
dnf install -y cloud-utils-growpart cloud-init
- resolv-conf
NOZEROCONF=yes
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
grub2-mkconfig -o /boot/grub2/grub.cfg
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
subscription-manager repos --disable=* subscription-manager unregister dnf clean all
poweroff
virt-sysprep -d <rhel9-cloud-image>
virt-sparsify --compress <rhel9.qcow2> <rhel9-cloud.qcow2>
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>
virt-viewer <rhel86-cloud-image>
TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=no
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
dnf -y update
dnf install -y cloud-utils-growpart cloud-init
- resolv-conf
echo "#" > /etc/udev/rules.d/75-persistent-net-generator.rules
NOZEROCONF=yes
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
subscription-manager repos --disable=* subscription-manager unregister dnf clean all
poweroff
virt-sysprep -d <rhel86-cloud-image>
virt-sparsify --compress <rhel86.qcow2> <rhel86-cloud.qcow2>
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>
--disk path=<file-name>,size=<size>
virt-viewer <windows-image>
openstack image create --file <base_image_file> uefi_secure_boot_image
openstack image set --property hw_machine_type=q35 uefi_secure_boot_image
openstack image set --property hw_firmware_type=uefi --property os_secure_boot=required uefi_secure_boot_image