Running Windows on the Amazon Elastic Compute Cloud with Qemu and Linux - Page 2

Want to support HowtoForge? Become a subscriber!
 
Submitted by enomaly (Contact Author) (Forums) on Fri, 2006-11-24 14:16. ::

5 Setting Up Amazon Environment

Amazon EC2 Command-Line Tools The command-line tools serve as the client interface to the Amazon EC2 web service. Use these tools to register and launch instances, manipulate security groups, and more.

Registering the AMI

Your image must be registered with Amazon EC2, so we can locate it and run instances based on it. Execute the following command to register the AMI you've just uploaded to Amazon S3:

PROMPT> ec2-register /image.manifest
IMAGE ami-61a54008

As output you will get an AMI identifier, the value next to the IMAGE tag (ami-61a54008 in the example) that can be used to run instances. Running Instances

You can now run an instance of the modified AMI by specifying the image identifier you received when you registered the image. Execute the following command, substituting the image identifier with that received in the section called “Registering the AMI”.

PROMPT> ec2-run-instances ami-61a54008
INSTANCE i-10a64379 ami-61a54008 pending

This will start a single instance based on your newly created AMI and provide you with an instance identifier, the value immediately to the right of the INSTANCE tag, that can be used to monitor the status of the running instance, as you did in the section called “Running an Instance”, to confirm the instance is up and running.

You now have your very own image starting up and getting ready. You can monitor its status until its ready and then connect to it with your web browser to confirm the changes you had made are actually live. Congratulations!

You have successfully built and deployed your very own AMI, and run instances based on it. This custom AMI is private to your account. You can build as many custom AMIs as you need and use them to launch as many instances as you need.

Authorizing Access to Your Instances

Before you can reach your instance over the internet, you have to authorize traffic to port that is responsible for remote administartion in our case it is port 3389:

ec2-authorize default -p 3389

 

6 Starting Windows at Amazon

Log in to your instance and setup system to startup windows automatically. I did it this way:

nano /root/.bashrc

add alias to save time:

alias win2003='nohup qemu -hda /dist/win2003srv.img -m 500 -boot c -redir tcp:3389::3389 -nographic &'

Note: you might have different choice for your hda disk.

Last thing is to actually start it, log off and log in back. Type our alias at last:

#win2003

Now it should be started automatically and stays running even if close your session.

 

7 Connecting to your windows

If you are using Windows XP go to 'Start > All programs > Accessories > Communication > Remote Desktop Connection'. Use access info that you set up during installation of windows.

At this point you should be playing inside windows.

 

8 Conclusion

Some of the benefits of QEMU running within an AMI;

  • Able to track usage variables. This would be ideal for web hosting and other various utility models.
  • Significantly lower per/hour costs by running several additional Virtual Machines per AMI. This would require a Qemu abstraction / accelerator.

You could foresee up to 15+ addition concurrent operation systems.

  • Able to more effectively simulate varied operating/hardware environments for easy migration from legacy systems.
  • Backups to S3 - Using the Qemu-img tool, instant snapshots can be saved to S3. Used with a versioning system, this could provide for unlimited roll backs.
  • VMware compatible - Qemu-img supports vmdk conversion as well as several other formats enabling easy migration from existing virtualized server environments.

One of the main hurdles that needs to be over come is in regards to the performance and overall speed of the emulated systems. To overcome this, a Qemu abstraction / accelerator will need to developed. This could be developed by us or any ambitious AMI users.

Another option for getting windows running, might be using a combo of para-virtualization (Xen) with a system abstraction layer tailored for optimal Windows performance. I should note, the new version of Xen supports Windows, but only with specific BIOS & CPU such as Intel VT.

A separate para-virtualized abstraction layer would allow you to compile an AMI image rather then a Qemu image. This would need to be developed by someone with internal access to EC2 and would require very new hardware.

 

9 Other Cool Stuff

Forget system restore and backup under XP. QEMU uses a concept called 'overlay images'. Once you have done your initial install, you can create an overlay image and run QEMU off this. The overlay image is very much smaller that the original image and will only contain changes made since the original install. If you trash your XP installation, you can simply delete the overlay image and create a new one from the original image. This is an ideal use in conjunction to Amazon's S3 storage services.

To create an overlay image, use the qemu-image program which is installed with QEMU. To create an image winxp.ovl from winxp.img, issue the following:

qemu-img create -b winxp.img -f qcow winxp.ovl

 

10 ScreenShot

93ff40018e.jpg

 

11 Resources

 

12 About authors

  • Reuven Cohen - Chief Technologist
  • Khaz Sapenov - Chief Architect

Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Richard (not registered) on Wed, 2009-10-14 16:21.
I just can't get remote desktop to work from the Linux host, even with the Windows Firewall disabled and the iptables flushed, and yes it is enabled.
Submitted by Richard (not registered) on Sat, 2010-01-23 18:48.

The solution for my issue:

sudo /usr/bin/nohup /usr/bin/qemu -hda /mnt/image_name.qcow2 -m 1000 -boot c  -localtime

Add on these to the command line args...
...for Win2K:  -vnc :1 &
This will activate the VNC server so Win2K can be accessed, and it even shows the Win2K startup screens
...for WinXP: -net nic,vlan=0 -net user,vlan=0 -redir tcp:3389::3389 -nographic &

Submitted by Anonymous (not registered) on Mon, 2008-10-06 22:28.

In step 4.1.2 creating windows image, in this command: qemu -hda winxp.img -cdrom yourDistro.iso -m 256 -boot d , I assume the yourDistro.iso iso9660 images is already uploaded to the linux AMI machine, how is this accomplished? is it by ftp or what?

 Also If I need to install or copy files to my AMI linux or windows OS, from a CD-rom media, how can, how can I do this?

Thanks! 

Submitted by Michael_Sheehan (registered user) on Mon, 2008-06-30 23:26.

I realize that this tutorial is probably a bit stale (I tried something similar on my macs using Qemu (actually Q - http://www.kju-app.org/ but that was some time ago).

Don't know if people are looking for alternatives for Windows (gasp) hosting on Amazon, but if you are, take a look at GoGrid . It's a true alternative to EC2. To be upfront, I'm the Technology Evangelist for GoGrid and have been asked by a lot of people about how to run Windows on EC2...you can't right now. That is part of the reason we released Windows AND Linux images on GoGrid.

Here is a quick comparison between GoGrid and EC2:  http://blog.gogrid.com/2008/06/17/comparison-gogrid-cloud-versus-amazon-ec2/

If you are just looking for a place to teach yourself Linux or actually roll out an implementation, give it a try! Let me know if anyone has questions.

 -Michael

Submitted by Alexey Bokov (not registered) on Thu, 2008-09-25 07:15.
I thought that converting VMWare images to AMI ( and running them after it ) is a most strange thing that people can do with amazon ec2, but now I can see that I was wrong. Running Windows under Qemu on elastic clouds is the strangest trick with amazon ec2. :-)