Cloud · Debian · Image Management · Linux Distribution · OpenStack

Bundling Debian 7.x image for OpenStack

The following procedure was tested using Debian 7.1.0 on Grizzly version of OpenStack.

Create an  image which emulates the Hard Drive

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

Boot the virtual machine

kvm -m 512 -cdrom  debian-7.1.0-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 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 SSH 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 file to OpenStack using the webUI.

Leave a Reply

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

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