Bundling Debian 6 image for OpenStack Essex

The following method was tested using Debian 6.0.6 on Essex version of OpenStack. The OpenStack cloud was setup using the procedure given in the following link.

OpenStack Beginner’s Guide V3.0

Create a raw image which emulates the Hard Drive.

kvm-img create -f qcow2 debian.img 5G

Start the Virtual Machine booting from the CD using the following command.

kvm -m 256 -cdrom debian-6.0.6-amd64-CD-1.iso -drive file=debian.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, during installation. Once the installation is over shutdown the Virtual Machine. Start the Virtual Machine to boot from the Hard Drive using the following command.

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

Do the necessary changes needed for the image.For key injection add the following lines before ‘exit 0’ in the file /etc/rc.local.

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

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

glance add name="Debian6" is_public=true container_format=ovf disk_format=qcow2 <debian.img

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

glance index

The output will be something like

ID            Name           Disk      Container  Size
                             Format    Format
-----------   ------------   -------   ---------- ----------
<Image-ID>    Debian6        qcow2     ovf        2399141888

Start the instance with the image that was uploaded.

nova boot --flavor 1 --image <Image-ID> --key_name mykey myinstance

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s