Creating the disk image
The following command creates the image of the virtual harddrive that KVM
emulates.
$ kvm-img create -f raw image.img 10G
Installing the VM
If Ubuntu 10.10 server is to be bundled, Install it in a VM using the following command
$ sudo kvm -m 512 -cdrom ubuntu-10.04.1-Desktop-i386.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 512 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 After Connecting use the following steps to configure VNC server in the VM image
Install TightVNC-server
$ sudo apt-get install tightvncserver
Configuring TightVNC-server
Now to check the installation run the following command
$ vncserver
Enter and confirm the password
Edit the file ~/.vnc/xstatup and add the following line
gnome-session &
Create a file /etc/init.d /vncserver. Now edit the file and add the following lines
#!/bin/sh -e ### BEGIN INIT INFO # Provides: vncserver # Required-Start: networking # Default-Start: S # Default-Stop: 0 6 ### END INIT INFO PATH="$PATH:/usr/X11R6/bin/" # The Username:Group that will run VNC export USER="" #${RUNAS} # The display that VNC will use DISPLAY="1" # Color depth (between 8 and 32) DEPTH="16" # The Desktop geometry to use. #GEOMETRY="x" #GEOMETRY="800x600" GEOMETRY="1024x768" #GEOMETRY="1280x1024" # The name that the VNC Desktop will have. NAME="my-vnc-server" OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}" . /lib/lsb/init-functions case "$1" in start) log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}" su ${USER} -c "/usr/bin/vncserver ${OPTIONS}" ;; stop) log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}" su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}" ;; restart) $0 stop $0 start ;; esac exit 0
Run the following command to make the file executable
$ sudo chmod +x /etc/init.d/vncserver
Run the following command
$ sudo update-rc.d enable vncserver
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
hi there… i have follow your instruction and finally.. my instances could go to running state .. but it cant get elastic IP (Public IP) do you have any idea?
am i need to changed the network eth0 to be DCHP mode?
Eucalyptus provides the IP to instance using the DHCP server running internally. Hence it expects the eth0 of the instance to start on DHCP mode.
hi,
I have follow instruction but when i tried to install desktop iso by typing command:
sudo kvm -m 512 -cdrom ubuntu-10.04.4-desktop-i386.iso -drive file=image.img, if=scsi,index=0 -boot d -net nic -net user -nographic -vnc :0
it is giving error message as:
open /dev/kvm: No such file or directory
Could not initialize KVM, will disable KVM support
pci_add_option_rom: failed to find romfile “pxe-rtl8139.bin”
inet_listen_opts: bind(ipv4,0.0.0.0,5900): Address already in use
inet_listen_opts: bind(ipv6,::,5900): Address already in use
inet_listen_opts: FAILED