Creating a Windows XP image file for OpenNebula Rel 3.4, using Virtual-shell script in a Ubuntu 11.10 64 bit server
All,welcome to my blog
Let’s discuss on how to create a Windows XP image file for OpenNebula Rel 3.4, using Virtual-shellscript in a Ubuntu 11.10 64 bit server
Normally we use KVM to create image files as it is a command line process. Let’s see how we can create an image file using a small virtual-shell script.
The advantage of using a âvirshâ script is it more manageable and easy to understand. Further kvm command line process requires frequent edits/changes while creating a Windows XP image. With virtual-shell scripts, at least we can minimize the number of changes.
Just have libvirt-bin , qemu-kvm and ubuntu-vm-builder installed to run the virtual shell script (or in libvirt language-to create a domain)
sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder |
(install bridge-utils only if you need a network bridge)
Just edit /etc/libvirt/qemu.conf and uncomment the line having the text vnc_listen = “0.0.0.0”
Then restart libvirt
sudo service libvirt-bin restart |
Let’s move to the process now,
Assume the Windows XP SP3 ISO file and the destination image file are stored in a folder /srv/cloud/one/images]
[Iam just using my OpenNebula images folder. You can have your own path.]
Create a 15 GB RAW image file using qemu-img-create command.
qemu-img create -f raw win-xp.img 15G |
In a editor create a file named âdeployment.1â and copy the following script in to it. Save the script in a folder. Mine is â/srv/cloud/one/var/images â
File : /srv/cloud/one/var/images/deployment.1
 domain type=’kvm’ xmlns:qemu=’http://libvirt.org/schemas/domain/qemu/1.0′><name>win-50</name><memory>1048576</memory><os><type arch=’i686′>hvm</type><boot dev=’hd’/><boot dev=’cdrom’/></os><on_reboot>restart</on_reboot><on_crash>restart</on_crash> <devices><emulator>/usr/bin/kvm</emulator><disk type=’file’ device=’disk’><source file=’/srv/cloud/one/images/win-xp.img’/><target dev=’hda’/><driver name=’qemu’ type=’raw’ cache=’default’/></disk> <disk type=’file’ device=’cdrom’><driver name=’qemu’ type=’raw’/><target dev=’hdc’ bus=’ide’/><readonly/><source file=’/srv/cloud/one/images/Win_XP_original.iso’/><address type=’drive’ controller=’0′ bus=’1′ unit=’0’/></disk> <controller type=’ide’ index=’0′><address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x01′ function=’0x1’/></controller> <!–use one network –><interface type=’network’><source network=’default’/></interface><graphics type=’vnc’ port=’5950’/</devices><features><acpi/></features></domain>
Let me not explain the script in detail now as content is self explanatory. I can explain it in detail, on request .
Providing the boot sequence âhdâ first and âcdromâ next will help us to avoid one edit to the script.
<boot dev=’hd’/>
<boot dev=’cdrom’/>
(i.e)On first execution of the script , libvirt finds that âhdâ is not bootable, and boots from âcdromâ
and on first reboot, the script automatically boots from the âhdâ
To execute the script, on the unix shell prompt type virsh and press enter.
Once you get the âvirsh #â prompt, type the below and press enter.>
create /srv/cloud/one/var/images/deployment.1 |
You will get an output stating -> “Domain Win-50 created from [path-of-file] “
Some possible failures while creating a domain through virtual shell:
Failed to create domain from /srv/cloud/one/var/images/deployment.1 err
- Check if service libvirt-bin is running, else start it and try above command now. Else,
- With âifconfigâ command check the existence of a bridge named virbr0 or virbr<n> {n will be 0 or a greater number} in VMHost.
- If not,check if dnsmasq is running in that machine. If yes, stop it and remove dnsmasq from the machine (apt-get remove dnsmasq) restart.
- >else reinstall libvirt-bin
- You will be able to see the bridge virtual bridge now.
Another method:[I donot recommended]
- check ifconfig for the virbr0 or anyother virtual bridge service.
- If not available replace virbr%d with the active bridge in your network, in the “default” n/w definition file /etc/libvirt/qemu/networks/default.xml
- restart libvirt service.
Â
error: Failed to create domain from /srv/cloud/one/images/deployment_1
error: internal error process exited while connecting to monitor: kvm: -drive file=/srv/cloud/one/images/win- xp.img,if=none,id=drive-ide0-0-0,format=raw: could not open disk image /srv/cloud/one/images/win-xp.img: Permission denied
e.g vncviewer 192.168.2.2:50 [50 is the VNC listening port]
Note: You will have a funny time using the mouse in a QEMU window. Just enjoy it. |
Just be patient. The partition formatting etc will be little slower through virsh.
In my next article, let’s discuss about how to change the script to use Intel e-1000 driver and how to use it in OpenNebula.
navaraja 3:27 pm on March 21, 2012 Permalink |
i followed the steps given
i able to create ubuntu instance also tried hadoop working fine.
all work fine…………
thanks
keepon posting similar site it would be greatfull to us
thanks……………….sir
bala 6:37 am on March 25, 2012 Permalink |
i tried to implement that hadoop using opennebula …
it’s working well…..
And follow that guide is to be easy to understand…..
Very thanks…
kyoko 2:19 am on November 30, 2012 Permalink |
thank’s a lot I’ll try it đ
cloudblab 5:48 am on November 30, 2012 Permalink |
Kyoko,
Thanks for choosing my document.
Good luck.
Regards,
Anil