Creating a Custom Image

This guide will help you to create a custom OpenStack image from a standard .iso. Currently, only Red Hat Enterprise Linux (RHEL) 6, RHEL 7, and Windows Server 2012 are discussed, though more distributions may be added in the future. For more information, refer to the OpenStack documentation here. (Note: In my own testing, I have found some of the content given in the OpenStack documentation to be incorrect, which is why this page exists).

For your convenience, the CRC has already created and tested images for RHEL 6 and RHEL 7 and has made them available for general use. You can find these CRC tested images, along with other tested images of other Linux distributions, on the 'Images' page under the 'Public' tab. All CRC tested images are prefixed with "CRC-".

Create a virtual machine using Virtual Machine Manager (VMM)

Create a container for your virtual machine

-Specify whatever name you like (in my case I used RHEL_6.6_x86-64.qcow2)
-The format must be qcow2
-Place it in whatever directory you like

qemu-img create -f qcow2 RHEL_6.6_x86-64.qcow2 2G

Create a new virtual machine in VMM

-give your virtual machine a name (e.g. RHEL_6.6)
-use local install
-click forward
-find the location of your .iso
-select the OS type and Version
-click forward
-select the amount of RAM and number of CPU's to allocate to your virtual machine; (note: Red Hat needs at least 2048 MB of RAM; check the system requirements for your particular operating system)
-click forward
-chose the "Select managed or other existing storage" option and find the location of the container you made in step 1
-click forward
-check the "Customize configuration before install" box
-click the Advanced options dropdown menu
-uncheck "Set a fixed Mac address"
-make sure that the NAT option is in the dropdown menu; it may not be VMM's default option
-click Finish
-click the Video tab, change model to VGA, then click Apply
-click the NIC tab, change model to virtio, then click Apply
-click the Disk tab, click the advanced drop down menu, change the disk bus to IDE, then click Apply
-click Begin Installation

Install RHEL 6

-choose the first Install option or wait for the autostart
-test your media by choosing OK and wait for it to finish
-click "Next"
-select your language and keyboard language
-select "Basic Storage Devices" then click "Next"
-click, "Yes, discard any data"
-click "Configure Network"
-click "System eth0" then click "Edit..."
-check the "Connect automatically" box, then click "Apply", then click "Close", then click "Next"
-choose your timezone then click "Next"
-enter a root password, then click "Next"
-select "Create Custom Layout", then click "Next"
-click "Free", then click "Create"
-make sure "Standard Partition" is selected, then click "Create"
-choose "/" as your mount point
-select the "Fill to maximum allowable size" option, then click "OK"
-click "Next"
-ignore the warning about swap, click "Yes", then click "Format", then click "Write changes to disk"
-click "Next"
-select "Minimal" and choose the "Customize now" option, then click "Next"
-under the Base System tab, choose the Base package
-*Optional: click the "Optional packages" button to remove any unnecessary packages. OpenSSH is needed.
-click "Next"
-get some popcorn and watch the install
-click "Reboot" once the installation has finished

back to top

Install RHEL 7

-choose the second install option or wait for the autostart; the install media will automatically be tested with this option
-select your language and keyboard language, then click "Continue"
-select "Network & Hostname", click "Configure", and select the General tab
-check "Automatically connect to this network when it is available", click "Save", then click the "Done" button in the upper left hand corner.
-select "Installation Destination", select "I will configure partitioning", then click the "Done" button
-click the dropdown menu and select "Standard Partition", then click the "+" button;
-enter "/" as the Mount Point and leave "Desired Capacity" blank; this will fill the partition to the maximum size; click "Add mount point"
-click the dropdown menu for "File System" and select "ext4"
-click the "Done" button twice; the installer will warn you about not using swap, but ignore it since this is the intention; click "Accept Changes"
-there is no need to modify the Software Selection, since Minimal Install is what we want
-click "Begin Installation"
-click "Root Password" and enter one, then click the "Done" button
-click "Reboot" once the installation has finished

back to top

Install Windows Server 2012

-choose your languages, then click Next
-click Install now
-select Windows Server 2012 (Server with a GUI), then click Next
-accept the license terms using the checkbox, then click Next
-click Custom: Install Windows only (advanced)
-ensure that the disk looks correct and that you don't need a driver, then click Next
-tap a nap while the installation completes
-enter an Administrator password, the click Finish.
-turn off Windows Firewall (Note: Firewall services are handled by OpenStack
-turn on Remote Desktop; move mouse to bottom right corner of screen, click settings, click server info, click Remote settings, click Allow remote connections, uncheck allow connections only from computers running Remote Desktop with Network Level Authentication
-download the VirtIO drivers from Fedora here
-click the "i" button in your virtual machine window, then click IDE CDROM
-click Connect and browse to find the location of the VirtIO .iso (you may already have an .iso connected. If so, just click Disconnect first).
-click the monitor icon to go back to your virtual machine
-open a PowerShell window and type the following command to install the VirtIO drivers. (Note: your CD drive label may be something other than E:)

C:\pnputil -i -a E:\WIN8\AMD64\*.INF

-tell Windows to allow allow all of the installations
-finish by activating and installing any updates as required

back to top

Modify a virtual machine to work with OpenStack

Prerequisites

In order for your Red Hat virtual machine to work with OpenStack, you must do the following:
-Your virtual machine / partition must fill the whole disk
-Your virtual machine / partition must be the only partition on the disk
-You must not have a /boot partition or a swap partition on your virtual machine
-Your virtual machine file system must be ext3 or ext4
-You will need the libguestfs-tools package installed on your host machine in order to prepare your virtual machine for OpenStack.

RHEL 6

- Login to your Red Hat virtual machine as the root user
- Register your Red Hat system if you have not done so already
- Update Red Hat using yum

yum update


- Restart the virtual machine

shutdown -r now


- Add (install) EPEL, if you don't already have it

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm


- Install the necessary cloud packages

yum install cloud-init dracut-modules-growroot.noarch acpid openssh


- Rebuild initramfs using dracut

dracut -f -v


- Make sure the ACPI daemon is set to start at boot

chkconfig acpid on


- Disable zero configuration networking

echo "NOZEROCONF=yes" >> /etc/sysconfig/network


- Replace/remove any evidence of the original MAC address

rm -f /etc/udev/rules.d/70-persistent-net.rules
touch /etc/udev/rules.d/70-persistent-net.rules

rm -f /lib/udev/rules.d/75-persistent-net-generator.rules
touch /lib/udev/rules.d/75-persistent-net-generator.rules


- Turn off the firewall (this will be managed by OpenStack instead)

chkconfig iptables off
chkconfig ip6tables off


- Add console support to the grub configuration file

vi /boot/grub/grub.conf
Find the first line that begins with kernel and add to the end of the line: console=ttyS0


- Modify the cloud configuration file

vi /etc/cloud/cloud.cfg
add: - growpart to the "cloud_init_modules:" section
add: resize_rootfs: TRUE above "resize_rootfs_tmp: /dev"
add: sudo: ["ALL=(ALL) NOPASSWD:ALL"] below "name: cloud-user" in the "default_user:" section under the "system_info:" section near the end of the file


- Exclude certain packages from getting updated via EPEL (these conflict with versions in official RHEL satellite-tools repository)

yum install yum-utils
yum-config-manager --setopt=epel.exclude=qpid-proton-c,python-qpid-proton --save


- Shutdown your Red Hat virtual machine

shutdown -h now


- Remove any network specific files from your virtual machine

virt-sysprep -d RHEL_6.6
(where RHEL_6.6 is the name of your virtual machine in VMM)


back to top

RHEL 7

- Login to your Red Hat virtual machine as the root user
- Register your Red Hat system if you have not done so already
- Update Red Hat using yum

yum update


- Restart the virtual machine

shutdown -r now


- Add (install) EPEL, if you don't already have it

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm


- Install the necessary cloud packages

yum install cloud-init cloud-utils-growpart acpid openssh


- Make sure the ACPI daemon is set to start on boot

systemctl enable acpid.service


- Disable zero configuration networking

echo "NOZEROCONF=yes" >> /etc/sysconfig/network


- Turn off the firewall (this will be managed by OpenStack instead)

systemctl disable firewalld 
systemctl stop firewalld


- Add console support to the grub configuration file

vi /etc/default/grub
add console=ttyS0 to the end of the "GRUB_CMDLINE_LINUX=" line, but inside the quotation mark
OR
Simply run this command:
sed -i '/GRUB_CMDLINE_LINUX/s|\"$| console=ttyS0\"|' /etc/default/grub


- Remake Grub

grub2-mkconfig -o /boot/grub2/grub.cfg


- Exclude certain packages from getting updated via EPEL (these conflict with versions in official RHEL satellite-tools repository)

yum install yum-utils
yum-config-manager --setopt=epel.exclude=qpid-proton-c,python-qpid-proton --save


- Shutdown your Red Hat virtual machine

shutdown -h now


- Remove any network specific files from your virtual machine

virt-sysprep -d RHEL_7.1
(where RHEL_7.1 is the name of your virtual machine in VMM)


back to top

Windows Server 2012

-Set the PowerShell execution policy to unrestricted in order to allow the cloudbase-init scripts to execute. Type "Y" when prompted.

C:\Set-ExecutionPolicy Unrestricted

-Download and install the cloudbase-init packages. This is an all-in-one installer for all of the cloud packages you need in order to get Windows Server 2012 to work with OpenStack.

C:\Invoke-WebRequest -UseBasicParsing http://www.cloudbase.it/downloads/CloudbaseInitSetup_Beta_x64.msi -OutFile cloudbaseinit.msi
C:\.\cloudbaseinit.msi

-once the installer starts, click Next
-accept the license agreement, then click Next
-click Next
-the username listed in this step will be the name of a user that cloudbase-init sets up. It is recommended that you change this from Admin to something else (such as cloud-user) in order for you to be able to administer this virtual machine from the OpenStack web-console.
-change Network adapter to configure to Red hat VirtIO Ethernet Adapter
-change Serial port for logging to COM1
-click Next, then click Install
-when the installation is finished, check both checkboxes, then click Finish

back to top

Load your image to OpenStack

If you have followed the above steps and created a qcow2 image to use with OpenStack, follow the instructions here to learn how to load your image to OpenStack. OpenStack calls this "creating an image."

back to top

OpenStack Main Page