[Openstack-operators] CentOS image

Robert Plestenjak robert.plestenjak at xlab.si
Tue Jun 11 09:35:01 UTC 2013


Yes, that would be great.

You can also create image manually in KVM, until proper tools are ready.

1. create disk image with QCOW2 format

qemu-img create -f qcow2 -o preallocation=metadata /extra/libvirt/images/centos-6-cloud.qcow2 2G

2. install centos, I recomend only one partition and no swap (in grizzly, you can set swap size in flavor)

virt-install --name=centos-6-cloud --disk path=/extra/libvirt/images/centos-6-cloud.qcow2,format=qcow2 -r 1024 --vcpus=1 --hvm -c /extra/iso/CentOS-6.3-x86_64-minimal.iso

3. login into your new image and modify '/etc/sysconfig/network-scripts/ifcfg-eth0' to look like this

DEVICE="eth0"
BOOTPROTO="dhcp"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"

4. add EPEL repository and update OS

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm

5. install cloud-utils and cloud-init

yum update
yum install cloud-utils, cloud-init

6. Download 'centos-image-mod.sh' and 'init-part' together in same directory, run 'centos-image-mod.sh'. This will modify initrd and grub.conf.

6.1. Edit '/boot/grub/grub.conf', check if everything is OK. Also, may not be a bad idea to set timeout to 0.

7. Delete '/etc/udev/rules.d/70-persistent-net.rules', this will be auto created during boot. Don't forget this, since you won't have functional network when you bring this image up on Openstack.

8. Power down your virtual Centos

9. Compress QCOW2 image with

qemu-img convert -c /extra/libvirt/images/centos-6-cloud.qcow2 -O qcow2 /tmp/centos.qcow2


Image /tmp/centos.qcow2 is now ready for upload to Openstack

- Robert


On 16 May 2013 21:08, Robert Plestenjak <robert.plestenjak at xlab.si> wrote:
> This script will modify initrd for image resize during boot, redirect boot log messages to ttyS0 and set NOOP sceduler. Tested on CentOS 6.3 and 6.4.
>
> https://github.com/flegmatik/centos-image-resize

This would be lovely to integrate into diskimage-builder [as part of a
CentOS supporting element].

-Rob

-- 
Robert Collins <rbtcollins at hp.com>
Distinguished Technologist
HP Cloud Services



More information about the OpenStack-operators mailing list