Bundling Linux image in UEC-Maverick Meerkat(10.10) and Eucalyptus version 2.0


Creating the disk image

The following command creates the image of the virtual harddrive that KVM
emulates.

$ kvm-img create -f raw image.img 5G

The option “qcow2” doesn’t work on UEC-Maverick Meerkat and Eucalyptus 2.0 installations. Hence it is important to create the KVM image in raw format, as eucalyptus starts the instance in raw option. If the image is created using qcow2 format,then while running the instance the console log of the instance gives an error saying “ALERT! /dev/sda1 does not exist. Dropping to a shell!”

Installing the VM

If Ubuntu 10.10 server is to be bundled, Install it in a VM using the following command

 $ sudo kvm -m 256 -cdrom ubuntu-10.10-server-amd64.iso -drive file=image.img,if=scsi,index=0 -boot d -net nic -net user -nographic -vnc :0

The memory needed for the VM changed accordingly using the -m option from 256 to appropriate memory size needed

Now connect to the VM using the following command

$ vncviewer A.B.C.D :0

Where A.B.C.D is the IP of the machine in which the VM is running

Key injection in instances

The following procedure can be followed to perform key injection in instances:

After the VM is installed relaunch the VM using the following command:

 sudo kvm -m 256 -drive file=image.img,if=scsi,index=0,boot=on -boot c -net nic -net user -nographic -vnc :0 

Install curl on the VM:

 sudo apt-get install curl 

Add the following lines to the /etc/rc.local before “exit 0”

depmod -a
modprobe acpiphp
# simple attempt to get the user ssh key using the meta-data service
# assuming “user” is the username of an account that has been created
mkdir -p /home/user/.ssh
echo >> /home/user/.ssh/authorized_keys
curl -m 10 -s http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key | grep 'ssh-rsa' >> /home/user/.ssh/authorized_keys
echo "AUTHORIZED_KEYS"
echo "************************"
cat /home/user/.ssh/authorized_keys
echo "************************"

Transferring the kernel and ramdisk to the host machine

The kernel and the ramdisk files of the VM are needed for registration with eucalyptus. Hence use the following commands to transfer the files from VM to the host machine.

$ scp /boot/initrd.img-2.6.35-22-server user@A.B.C.D:
$ scp /boot/vmlinuz-2.6.35-22-server user@A.B.C.D:

Removing the network persistent rules

Now remove the network persistent rules from /etc/udev/rules.d, so that the instance always comes up with eth0 as the network interface, using the following command

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

Registering with UEC or Eucalyptus

Registering kernel image

Execute the following commands to bundle and register the kernel image (vmlinuz-2.6.35-22-server)

$ euca-bundle-image -i vmlinuz-2.6.35-22-server --kernel true
$ euca-upload-bundle -b mybucket -m /tmp/vmlinuz-2.6.35-22-server.manifest.xml
$ euca-register mybucket/vmlinuz-2.6.35-22-server.manifest.xml

Save the output produced by the last command above (eki-XXXXXXXX), which will be needed while registering the disk image.

Registering ramdisk image

Execute the following commands to bundle and register the ramdisk image (initrd.img-2.6.35-22-server)

$ euca-bundle-image -i  initrd.img-2.6.35-22-server --ramdisk true
$ euca-upload-bundle -b mybucket -m /tmp/initrd.img-2.6.35-22-server.manifest.xml
$ euca-register mybucket/initrd.img-2.6.35-22-server.manifest.xml

Save the output produced by the last command above (eri-XXXXXXXX), which will be needed while registering the disk image.

Registering disk image

Execute the following commands to bundle and register the ramdisk image (image.img)

$ euca-bundle-image -i image.img --kernel eki-XXXXXXXX --ramdisk eri-XXXXXXXX
$ euca-upload-bundle -b mybucket -m /tmp/image.img.manifest.xml
$ euca-register mybucket/image.img.manifest.xml

Replace eki-XXXXXXXX and eri-XXXXXXXX with the exact values you have saved earlier.

Checking the registration

To check whether registration has succeeded, use the following command

$ euca-describe-images

The output should be like

IMAGE   emi-70B70EC0    mybucket/image.img.manifest.xml                     admin   available        public  x86_64  machine
IMAGE   eri-A2BE13EC    mybucket/initrd.img-2.6.35-22-server.manifest.xml   admin    available       public  x86_64  ramdisk
IMAGE   eki-685F1306    mybucket/vmlinuz-2.6.35-22-server.manifest.xml      admin    available       public  x86_64  kernel
Advertisements

2 thoughts on “Bundling Linux image in UEC-Maverick Meerkat(10.10) and Eucalyptus version 2.0

    1. Hi Walt,
      It is not a bug in eucalyptus, but the updated versions of eucalyptus (Including Version 1.6), passes a specific option ‘format=raw’ to the KVM command while bringing up an instance. Hence it doesn’t support qcow2 format.

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