CSS Corp Open Source Services

Bundling OpenSUSE image for OpenStack

leave a comment »

This article explains how to create a OpenSUSE 11.4 image on KVM for uploading it to the image store on OpenStack Diablo.  I have used KVM running on Ubuntu 11.10 64-bit server for creation of the image.

 The first step would be to create a qcow2 image. This will represent the main HDD of the virtual machine, so make sure to give it as much space as you will need.
kvm-img create -f qcow2 opensuse.img 5G

Start the Virtual Machine booting from the CD.

kvm -m 512 -cdrom openSUSE-11.4-DVD-x86_64.iso -drive file=opensuse.img,if=virtio,index=0 -boot d -net nic -net user -nographic -vnc :1

Connect to the Virtual Machine through VNC (use display number :1).For Example, where is the IP address of the host machine.

vncviewer :1

Select SSH server, Curl and other packages needed. Once the installation is over shutdown the Virtual Machine and boot the  Virtual Machine from Hard Drive using the following command.

kvm -m 512 -drive file=opensuse.img,if=virtio,index=0,boot=on -boot c -net nic -net user -nographic -vnc :1

Install SSH server

zypper install openssh

Install curl

zypper install curl

For SSH Key injection into the instance use the following steps:

Create a file /etc/init.d/sshkey and add the following lines

echo >> /root/.ssh/authorized_keys
curl -m 10 -s | grep 'ssh-rsa' >> /root/.ssh/authorized_keys
echo "************************"
cat /root/.ssh/authorized_keys
echo "************************"

Change the permissions for the file

chmod 755 /etc/init.d/sshkey

Configure the service to start automatically while booting

chkconfig sshkey on

Configure the firewall (Not iptables) using the following command and allow ssh service


Also remove the network persistence rules from /etc/udev/rules.d as their presence will result in the network interface in the instance coming up as an interface other than eth0.

rm -rf /etc/udev/rules.d/70-persistent-net.rules

Shutdown the Virtual Machine. Upload the image to OpenStack using the following command

cloud-publish-image amd64 opensuse.img opensusebucket

The following output shows that the image has been successfully uploaded.

ami-00000001 opensusebucket/opensuse.img.manifest.xml

Verify whether the instance boots from the uploaded image.

euca-run-instances ami-00000001 -k mykey -t m1.tiny

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: