Running Windows on the Amazon Elastic Compute Cloud with Qemu and Linux - Page 2
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
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:
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:
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.
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
- QEMU Homepage (http://fabrice.bellard.free.fr/qemu/)
- Ubuntu emulated in Windows with QEMU (http://homepage.sunrise.ch/mysunrise/ekeller00/EricKellerUbuntuPage.html)
- Forum thread about the script used in this article (http://www.ubuntuforums.org/showthread.php?t=187413)
- Original Tutorial (https://help.ubuntu.com/community/WindowsXPUnderQemuHowTo)
- Qemu in Windows tutorial
12 About authors
- Reuven Cohen - Chief Technologist
- Khaz Sapenov - Chief Architect