How to create OpenStack Cloud Images for KVM and PowerKVM

Here I’m illustrating how to create your own OpenStack images for use with KVM compute nodes. I’ll be taking the example of PowerKVM compute node. However, the same instruction applies for Intel/KVM as well.

Step-1. Create an image of the required size.

#qemu-img create -f qcow2 /var/lib/libvirt/images/rhel6-cloud.qcow2 +8G

where /var/lib/libvirt/images is the location to place the image, and rhel6-cloud.qcow2 is the name of the image file.

Step-2. Install required operating system on the image.

#virt-install --machine=pseries --name=rhel6-cloud --virt-type=kvm --boot cdrom,hd --network=default,model=virtio --disk path=/var/lib/libvirt/images/rhel6-cloud.qcow2,format=qcow2,bus=virtio,cache=none --memory=4096 --vcpu=2 --cdrom=/RHEL6.5-20131111.0-Server-ppc64-DVD1.iso

 

virt-install will create a definition of the VM, and start the installation process from the cdrom. Further, it will automatically connect to the serial console of the VM as shown in the screen-shot below.

Clipboard01

Clipboard02Clipboard03Reboot the image after installation.

Step-3. Perform post install configuration:

  1. Install and configure any application that you might need as part of the image. For eg, install cloud-init, cloud-utils, cloud-utils-growpart and related tools for ensuring automatic disk image resize, user and ssh-key configuration
  2. Set ‘ONBOOT=yes’ in /etc/sysconfig/network-scripts/ifcfg-eth0
  3. Shut down the instance (shutdown -h now)

Step-4. Clean up the image for use in cloud

The operating system records the MAC address of the virtual NIC in multiple locations, and if these are not removed then the virtual NIC will have a different MAC address every time it reboots. This can be done by manually removing the entries from the specific locations. However, this is tedious and error prone. Fortunately, there is a much easier way.

One can use the utility called virt-sysprep, that performs various cleanup tasks for the image. It’s part of libguestfs-tools package on RedHat based systems.

# virt-sysprep -d rhel6-cloud

Step-5. Upload the VM image to Glance – the OpenStack image service.

# glance image-create --name=rhel-cloud --is-public=true --disk-format=qcow2 \
--container-format=bare --file=/var/lib/libvirt/images/rhel6-cloud.qcow2 --property architecture=ppc64

For Intel/KVM its not required to specify the architecture property. Default image architecture is x86_64 (Intel)

Clipboard04

Check if the image successfully got uploaded to Glance or not

# glance image-list

Clipboard05Now you can use the new uploaded image to provision instances.

 

 

Pradipta Kumar Banerjee

I'm a Cloud and Linux/ OpenSource enthusiast, with 16 years of industry experience at IBM. You can find more details about me here - Linkedin

You may also like...