github linkedin
Rebuild CirrOS tiny cloud image for VMware
We’ve faced problems when tried to boot CirrOS tiny cloud image as guest OS on VMware ESXi managed by OpenStack.

Problem description: It boots up without any storage disk or NIC. By default OpenStack (with VMwareESXDriver) uses LSILogic SCSI controler (Fusion MPT) for VMware guests. Seems like there is no drivers(modules) for this type of SCSI controler. Let’s try to add it.

To add this additional drivers we need to rebuild CirrOS as described in official README . I’ve done all stuff on Ubuntu 12.04 LTS.

* Get build dependencies, clone source code repo.

sudo apt-get -y install bison flex texinfo build-essential gettext ncurses-dev unzip bzr qemu-kvm cvs quilt
bzr branch lp:cirros
cd cirros

* Download buildroot and setup environment and apply local cirros patches to it.

br_ver=”2012.05″
mkdir -p ../download
ln -snf ../download download
( cd download && wget http://buildroot.uclibc.org/downloads/buildroot-${br_ver}.tar.gz )
tar -xvf download/buildroot-${br_ver}.tar.gz
ln -snf buildroot-${br_ver} buildroot
./bin/mkcabundle > src/etc/ssl/certs/ca-certificates.crt
( cd buildroot && QUILT_PATCHES=$PWD/../patches-buildroot quilt push -a )
make ARCH=i386 br-source

 * Build buildroot for a given arch. ARCH should be set to ‘i386’, ‘x86_64’ or ‘arm’.

make ARCH=i386 OUT_D=$PWD/output/i386

This will do a full buildroot build, which will take a while. The output that CirrOS is interested in is output/i386/rootfs.tar. That file is the full buildroot filesystem, and is used as input for subsequent steps here.

 * Download a kernel to use. I’ve used ubuntu virtual i386 kernel.

wget https://launchpad.net/ubuntu/+archive/primary/+files/linux-image-3.2.0-41-virtual_3.2.0-41.66_i386.deb -O download/linux-image-3.2.0-41-virtual_3.2.0-41.66_i386.deb

* Patch cirros bundle script. In simple, this script used to rebuild rootfs.tar with custom kernel. It creates two initramfs files: “standart” and “smaller” w/o kernel modules. By default it uses second one. To prevent it and use standart initramfs do:

sed -i ‘s/cp “${initramfs}.smaller”/cp “${initramfs}”/’ bin/bundle

* Add necessary kernel modules. Bundle script gets modules to include in image from “src/etc/modules” . For Fusion MPT devices (i.e. lsiLogic scsi controller) support add “mptbase” and “mptscsih” modules:

echo -e “mptbasenmptscsih” >> src/etc/modules

*  build disk images using special script bin/bundle

sudo ./bin/bundle -v output/$ARCH/rootfs.tar download/linux-image-3.2.0-41-virtual_3.2.0-41.66_i386.deb output/$ARCH/images

Resulting images located in output/i386/images . You could use bootable qcow2 image “output/i386/images/disk.img” or ami (blank.img), ari (initramfs), aki (kernel). OpenStack supports now only flat vmdk images for vmware and we need to convert qcow2 to raw:

qemu-img convert -O raw output/i386/images/disk.img output/i386/images/disk-raw.img

How to add image to glance:

glance add name=”cirros-vmware” disk_format=raw container_format=bare is_public=true vmware_adaptertype=”lsiLogic” vmware_disktype=”preallocated” vmware_ostype=”otherGuest” < disk-raw.img