Chapter 4. Images and Storage
This chapter discusses the steps you can follow to manage images and storage in RHEL OpenStack Platform.
A virtual machine image is a file that contains a virtual disk which has a bootable operating system installed on it. Virtual machine images are supported in different formats. The following are the formats available on RHEL OpenStack Platform:
RAW- Unstructured disk image format.QCOW2- Disk format supported by QEMU emulator.ISO- Sector-by-sector copy of the data on a disk, stored in a binary file.AKI- Indicates an Amazon Kernel Image.AMI- Indicates an Amazon Machine Image.ARI- Indicates an Amazon RAMDisk Image.VDI- Disk format supported by VirtualBox virtual machine monitor and the QEMU emulator.VHD- Common disk format used by virtual machine monitors from VMWare, VirtualBox, and others.VMDK- Disk format supported by many common virtual machine monitors.
While we don't normally think of ISO as a virtual machine image format, since ISOs contain bootable filesystems with an installed operating system, you can treat them the same as you treat other virtual machine image files.
To download the official Red Hat Enterprise Linux cloud images, you require a valid Red Hat Enterprise Linux subscription:
4.1. Manage Images
The OpenStack Image service (glance) provides discovery, registration, and delivery services for disk and server images. It provides the ability to copy or snapshot a server image, and immediately store it away. Stored images can be used as a template to get new servers up and running quickly and more consistently than installing a server operating system and individually configuring additional services.
4.1.1. Create an Image
This section provides you with the steps to manually create OpenStack-compatible images in .qcow2 format using Red Hat Enterprise Linux 6 and Red Hat Enterprise Linux 7 ISO files.
4.1.1.1. Use a KVM Guest Image With RHEL OpenStack Platform
You can use a ready RHEL KVM guest qcow2 image available at: RHEL 7 KVM Guest Image or RHEL 6.6 KVM Guest Image. These images are configured with
cloud-init and must take advantage of ec2-compatible metadata services for provisioning SSH keys in order to function properly.
Note
For the KVM guest images:
- The
rootaccount in the image is disabled, butsudoaccess is granted to a special user namedcloud-user. - There is no
rootpassword set for this image.Therootpassword is locked in/etc/shadowby placing!!in the second field.
For an OpenStack instance, it is recommended that you generate an
ssh keypair from the OpenStack dashboard or command line and use that key combination to perform an SSH public authentication to the instance as root.
When the instance is launched, this public key will be injected to it. You can then authenticate using the private key downloaded while creating the keypair.
If you want to create custom Red Hat Enterprise Linux images, see Section 4.1.1.2.1, “Create a Red Hat Enterprise Linux 7 Image” or Section 4.1.1.2.2, “Create a Red Hat Enterprise Linux 6 Image”.
4.1.1.2. Create Custom Red Hat Enterprise Linux Images
Prerequisites:
- Linux host machine to create an image. This can be any machine on which you can install and run the Linux packages.
- libvirt, virt-manager (run command yum groupinstall @virtualization). This installs all packages necessary for creating a guest operating system.
- Libguestfs tools (run command yum install libguestfs-tools-c). This installs a set of tools for accessing and modifying virtual machine images.
- A Red Hat Enterprise Linux ISO file (see RHEL 7.0 Binary DVD or RHEL 6.6 Binary DVD ).
- Text editor, if you want to change the
kickstartfiles.
Note
In the following procedures, all commands with the
[user@host]# prompt should be run on your host machine.
4.1.1.2.1. Create a Red Hat Enterprise Linux 7 Image
This section provides you with the steps to manually create an OpenStack-compatible image in .qcow2 format using a Red Hat Enterprise Linux 7 ISO file.
- Start the installation using virt-install:
[user@host]#qemu-img create -f qcow2 rhel7.qcow2 8G[user@host]#virt-install --virt-type kvm --name rhel7 --ram 2048 \--cdrom /tmp/rhel-server-7.0-x86_64-dvd.iso --disk rhel7.qcow2,format=qcow2 \--network=bridge:virbr0 --graphics vnc,listen=0.0.0.0 \--noautoconsole --os-type=linux --os-variant=rhel7This launches an instance and starts the installation process.NoteIf the instance does not launch automatically, run the following command to view the console:[user@host]#virt-viewer rhel7 -
Set up the virtual machine as follows:
- At the initial Installer boot menu, choose the
Install Red Hat Enterprise Linux 7.0option.
- Choose the appropriate
LanguageandKeyboardoptions. - When prompted about which type of devices your installation uses, choose
Auto-detected installation media.
- When prompted about which type of installation destination, choose
Local Standard Disks.
For other storage options, chooseAutomatically configure partitioning. - For software selection, choose
Minimal Install. - For network and hostname, choose
eth0for network and choose ahostnamefor your device. The defaulthostnameislocalhost.localdomain. - Choose the root password.
The installation process completes and theComplete!screen appears.
- After the installation is complete, reboot the instance and log in as the root user.
- Update the
/etc/sysconfig/network-scripts/ifcfg-eth0file so it only contains the following values:TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=no
- Reboot the machine.
- Register the machine with the Content Delivery Network:
#subscription-manager register- Enter your Customer Portal user name and password when prompted:
Username: admin@example.com Password:
- Find entitlement pools containing the channel:
#subscription-manager list --available | grep -A8 "Red Hat Enterprise Linux Server" - Use the pool identifiers located in the previous step to attach the
Red Hat Enterprise Linux Serverentitlement to the system:#subscription-manager attach --pool=pool_id - Enable the required channel:
#subscription-manager repos --enable=rhel-7-server-rpmsFor RHEL OpenStack Platform 6, the required channels arerhel-7-server-openstack-6.0-rpmsandrhel-7-server-rh-common-rpms.NoteFor more information, see Software Repository Configuration
- Update the system.
#yum -y update - Install the
cloud-initpackages.#yum install -y cloud-utils-growpart cloud-init - Edit the
/etc/cloud/cloud.cfgconfiguration file and undercloud_init_modulesadd:- resolv-conf
Theresolv-confoption automatically configures theresolv.confconfiguration 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/networkto avoid problems accessing the EC2 metadata service.NOZEROCONF=yes
- To ensure the console messages appear in the
Logtab on the dashboard and the nova console-log output, add the following boot option to the/etc/default/grubfile:GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
Run the following command:#grub2-mkconfig -o /boot/grub2/grub.cfgThe output is as follows:Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-229.7.2.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-229.7.2.el7.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-121.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-121.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-b82a3044fb384a3f9aeacf883474428b Found initrd image: /boot/initramfs-0-rescue-b82a3044fb384a3f9aeacf883474428b.img done
- Un-register the virtual machine so that the resulting image does not contain the same subscription details for every instance cloned based on it.
#subscription-manager repos --disable=*#subscription-manager unregister#yum clean all - Power off the instance:
#poweroff - Reset and clean the image using the virt-sysprep command so it can be to create instances without issues:
[user@host]#virt-sysprep -d rhel7 - Reduce the size of the image using the virt-sparsify command. This command converts any free space within the disk image back to free space within the host:
[user@host]#virt-sparsify --compress rhel7.qcow2 rhel7-cloud.qcow2This creates a newrhel7-cloud.qcow2file in the location from where the command is run.
The
rhel7-cloud.qcow2 image file is ready to be uploaded to the Image service. For more information on uploading this image to your OpenStack deployment using the dashboard, see Section 4.1.2, “Upload an Image”.
4.1.1.2.2. Create a Red Hat Enterprise Linux 6 Image
This section provides you with the steps to manually create an OpenStack-compatible image in .qcow2 format using a Red Hat Enterprise Linux 6 ISO file.
- Start the installation using virt-install:
[user@host]#qemu-img create -f qcow2 rhel6.qcow2 4G[user@host]#virt-install --connect=qemu:///system --network=bridge:virbr0 \--name=rhel6.6 --os-type linux --os-variant rhel6 \--disk path=rhel6.qcow2,format=qcow2,size=10,cache=none \--ram 4096 --vcpus=2 --check-cpu --accelerate \--hvm --cdrom=rhel-server-6.6-x86_64-dvd.isoThis launches an instance and starts the installation process.NoteIf the instance does not launch automatically, run the following command to view the console:[user@host]##virt-viewer rhel6 - Set up the virtual machines as follows:
- At the initial Installer boot menu, choose the
Install or upgrade an existing systemoption.
Step through the installation prompts. Accept the defaults.The installation checks for disc and performs aMedia Check. When the check is aSuccess, it ejects the disc. - Choose the appropriate
LanguageandKeyboardoptions. - When prompted about which type of devices your installation uses, choose
Basic Storage Devices.
- Choose a
hostnamefor your device. The defaulthostnameislocalhost.localdomain. - Set
timezoneandroot password. - Based on the space on the disk, choose the type of installation.

- Choose the
Basic Serverinstall, which installs an SSH server.
The installation process completes andCongratulations, your Red Hat Enterprise Linux installation is completescreen appears.
- Reboot the instance and log in as the
rootuser. - Update the
/etc/sysconfig/network-scripts/ifcfg-eth0file so it only contains the following values:TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=no
- Reboot the machine.
- Register the machine with the Content Delivery Network:
#subscription-manager register- Enter your Customer Portal user name and password when prompted:
Username: admin@example.com Password:
- Find entitlement pools containing the channel:
#subscription-manager list --available | grep -A8 "Red Hat Enterprise Linux Server" - Use the pool identifiers located in the previous step to attach the
Red Hat Enterprise Linux Serverentitlement to the system:#subscription-manager attach --pool=pool_id - Enable the required channel:
#subscription-manager repos --enable=rhel-6-server-rpmsFor RHEL OpenStack Platform 6, the required channels arerhel-7-server-openstack-6.0-rpmsandrhel-6-server-rh-common-rpms.NoteFor more information, see Software Repository Configuration
- Update the system.
#yum -y update - Install the
cloud-initpackages.#yum install -y cloud-utils-growpart cloud-init - Edit the
/etc/cloud/cloud.cfgconfiguration file and undercloud_init_modulesadd:- resolv-conf
Theresolv-confoption automatically configures theresolv.confconfiguration 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.rulesfile.#echo "#" > /etc/udev/rules.d/75-persistent-net-generator.rulesThis prevents/etc/udev/rules.d/70-persistent-net.rulesfile from being created. If/etc/udev/rules.d/70-persistent-net.rulesis created, networking may not function properly when booting from snapshots (the network interface is created as "eth1" rather than "eth0" and IP address is not assigned). - Add the following line to
/etc/sysconfig/networkto avoid problems accessing the EC2 metadata service.NOZEROCONF=yes
- To ensure the console messages appear in the
Logtab on the dashboard and the nova console-log output, add the following boot option to the/etc/grub.conf:console=tty0 console=ttyS0,115200n8
- Un-register the virtual machine so that the resulting image does not contain the same subscription details for every instance cloned based on it.
#subscription-manager repos --disable=*#subscription-manager unregister#yum clean all - Power off the instance:
#poweroff - Reset and clean the image using the virt-sysprep command so it can be to create instances without issues:
[user@host]#virt-sysprep -d rhel6.6 - Reduce image size using the virt-sparsify command. This command converts any free space within the disk image back to free space within the host:
[user@host]#virt-sparsify - -compress rhel6.qcow2 rhel6-cloud.qcow2This creates a newrhel6-cloud.qcow2file in the location from where the command is run.
Note
You will need to 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
rhel6-cloud.qcow2 image file is ready to be uploaded to the Image service. For more information on uploading this image to your OpenStack deployment using the dashboard, see Section 4.1.2, “Upload an Image”.
4.1.2. Upload an Image
- In the dashboard, select Project > Compute > Images.
- Click .
- Fill out the values, and click when finished.
Field Notes Name Name for the image. The name must be unique within the project. Description Brief description to identify the image. Image Source Image source: Image Location or Image File. Based on your selection, the next field is displayed.Image Location or Image File - Select Image Location option to specify the image location URL.
- Select Image File option to upload an image from the local disk.
Format Image format (for example, qcow2). Architecture Image architecture. For example, use i686 for a 32-bit architecture or x86_64 for a 64-bit architecture. Minimum Disk (GB) Minimum disk size required to boot the image. If this field is not specified, the default value is 0 (no minimum). Minimum RAM (MB) Minimum memory size required to boot the image. If this field is not specified, the default value is 0 (no minimum). Public If selected, makes the image public to all users with access to the project. Protected If selected, ensures only users with specific permissions can delete this image.
Note
You can also use the glance image-create command with the
property option to create an image. More values are available on the commmand line. For a complete listing, see Appendix A, Image Configuration Parameters.
4.1.3. Update an Image
- In the dashboard, select Project > Compute > Images.
- Click Edit.NoteThe option is available only when you login as an
adminuser. When you login as ademouser, you have the option to Launch an instance or Create Volume. - Update the fields and click Update Image when finished. You can update the following values - name, description, kernel ID, ramdisk ID, architecture, format, minimum disk, minimum RAM, public, protected.
- Click the dropdown menu and select Update Metadata option.
- Specify metadata by adding items from the left column to the right one. In the left column, there are metadata definitions from the Image Service Metadata Catalog. Select Other to add metadata with the key of your choice and click when finished.
Note
You can also use the glance image-update command with the
property option to update an image. More values are available on the commmand line; for a complete listing, see Appendix A, Image Configuration Parameters.
4.1.4. Delete an Image
- In the dashboard, select Project > Compute > Images.
- Select the image you want to delete and click .