Tilt-logo

Things I Learned Today - our daily eureka-moments

Carr
proppi
Edland
feenyx
Programming .NET VS2010 Web Windows VS2012 S3 Search SQL SqlMetal Accessibility Amazon Android App BBQ EBS EC2 Exchange Food Garmin Geocaching GPS Grill Java Linq Lucene MVC PowerShell

Amazon EC2: moving an S3-backed windows 2003 instance to EBS-backing - Carr, 25.10.2011

I'm the caretaker of an old (well, a couple of years) Windows 2003 server cloud-hosted at Amazon EC2. The server was S3-backed, which simply put means that the OS lives on non-persistent storage. If it was ever terminated, the OS config would be dead and gone (a recent AMI nonwithstanding).

In december 2009, Amazon enabled us to boot instances from an EBS volume instead. See this blog entry for details. One of many good things about this is the ability to terminate the instance, but keep the OS volume and attach it to another instance.

So, I set out to migrate my instance. The following process is annotated text from a PDF found at cloudfront.net, only referenced from a couple of forum posts. If anyone knows who the author is, or has an original source, let me know.



1. Launch an instance of the S3-backed Windows AMI that you want to migrate

2. Log into the instance and download dd.exe. This is a *nix tool that does block copying of raw devices. We tested with version dd-0.5 from http://www.chrysocome.net/dd, although the newer versions appear to work too

3. Create a 10GB EBS volume in the same AZ as the running instance and attach it to the running instance. You don’t need to mount it or format it. It will show up in the Disk Manager and the dd tool will see the raw device

4. Stop all running services and programs, then run a dd copy from the root disk to the mounted EBS volume. This is done on the running S3-backed instance. This command worked in our tests: dd if=\\?\Device\Harddisk0\Partition0 of=\\?\Device\Harddisk2\Partition0 bs=1M --size --progress


5. Once dd completes, detach the EBS volume from the S3-backed instance and note its volume id

6. Launch an EBS-backed Basic Windows instance of the same bit size (32 or 64 bit) as your S3-backed AMI and in the same AZ. There are some EBS-backed Windows 2003 images available

7. Stop the EBS-backed Windows instance

8. Detach the EBS root volume from the EBS-backed Windows instance

9. Attach the EBS volume that was cloned from the S3-backed root volume using DD. This needs to be attached as /dev/sda1 (yes, even on windows)

10. Start the EBS-backed Windows instance

11. Connect to the EBS-backed Windows instance and confirm that it works



.. and that's it. Detach any elastic IP's from the old instance and reattach to the new one, and you should be back in production!
Tags: Amazon EC2 S3 EBS Windows
Comments:
Nobody has commented on this post yet. Feel free to be the first!