CSS Corp Open Source Services

Bundling Debian image for OpenStack

with 5 comments

This article explains how to create a Debian 6 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 debian.img 5G

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

kvm -m 512 -cdrom debian-6.0.1a-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 10.10.10.1 is the IP address of the host machine.

vncviewer 10.10.10.1 :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.

kvm -m 512 -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 in the file /etc/rc.local.

mkdir -p /root/.ssh
echo >> /root/.ssh/authorized_keys
curl -m 10 -s http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key | grep 'ssh-rsa' >> /root/.ssh/authorized_keys
echo "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

cloud-publish-image amd64 debian.img debianbucket

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

ami-00000001 debianbucket/debian.img.manifest.xml

Verify whether the instance boots from the uploaded image.

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

5 Responses

Subscribe to comments with RSS.

  1. I’ve followed your instruction.

    root@kia:~# cloud-publish-image amd64 DEBIAN-TEMLATE.img debianbucket
    ami-0000000b debianbucket/DEBIAN-TEMLATE.img.manifest.xml

    But image is available.

    root@kia:~# euca-run-instances ami-0000000b -k pk.pem -t m1.tiny
    ApiError: Image must be available

    Output of euca-describe-images command:

    root@kia:~# euca-describe-images
    IMAGE ami-0000000b debianbucket/DEBIAN-TEMLATE.img.manifest.xml failed_decrypt private x86_64 machine instance-store

    Help, please.

  2. when I mount iso image with
    sudo mount -t iso9660 -o loop /home/reza/ubuntu-11.10-server-amd64.iso /cdrom

    and use command you mentioned like
    sudo kvm -m 256 -cdrom ubuntu-11.10-server-amd64.iso -drive file=server.img,if=scsi,index=0 -boot d -net nic -net user -nographic -vnc :0

    nothing happens for a long time (3 hours) and I have to restart the system because of high cpu usage.
    can you help me?
    thanks

    Reza

    February 13, 2012 at 3:32 am

  3. Hi,
    when I do “cloud-publish-image amd64 debian.img debianbucket”
    I receive this error:
    failed to check for existing manifest

    how I can solve it?

    Reza

    February 27, 2012 at 2:04 am

  4. […] Bundling Debian image for OpenStack ≪ CSS Corp Open Source Services […]

  5. what about cloud-init package? how this image can be resized by flavors?

    Roman Gorodeckij

    August 24, 2013 at 10:04 am


Leave a comment