Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have a Windows server (EBS backed) running in EC2. We make regular snapshots for data backups. I'd like to create a new EC2 instance from one of these snapshots.

Yes, I realise this is the same as yanking out the power and turning a machine on, but I want to test how reliable the data is within the snapshots for recovery purposes.

I've tried using the web console, command line tools and ruby sdk to create an AMI image from a snapshot of our Windows boot drive (EBS) - they all create an AMI that shows the platform as Linux instead of Windows and paravirtual virtualisation instead of hvm. A new EC2 instance created from this AMI fails to ever come online, I'm supposing it crashes because it's running on the wrong virtualisation platform.

Of all the googling I've done, I've only come across Linux instructions, or instructions for making a Windows EBS from an Instance backed EC2 instance - not an EBS backed one, or a snapshot.

share|improve this question

migrated from superuser.com Feb 1 '12 at 11:23

This question came from our site for computer enthusiasts and power users.

2 Answers 2

up vote 4 down vote accepted

Background

Launching an Instance from a Snapshot is not available for Windows AMIs (as you have meanwhile discovered yourself):

Important

Registering a snapshot works only for Linux/UNIX AMIs; although you can register a snapshot to create a Windows AMI, the AMI isn't launchable. [emphasis mine]

Alternative

While not specified, one should be aware of the possibility to simply clone an Amazon EBS-Backed Instance as outlined in Creating an Image from a Running Instance - when doing this via the AWS Management Console like so, EC2 attempts to cleanly shut down the instance before image creation and reboots the instance afterwards. This is obviously generally preferable, however, it can be avoided via the command line, if so desired:

If you prefer the instance not be rebooted, you can use the Amazon EC2 command line tools to create the image [...]. The ec2-create-image command has a --no-reboot option.

Solution

The alternative approach mentioned above obviously won't help to create a new EC2 instance from one of these snapshots as specified - a solution useful to be aware of anyway is outlined in section Moving to a New Instance of Eric Hammond's article Move a Running EBS Boot Instance to New Hardware on Amazon EC2 (which has a different use case, but applies regardless) and boils down to these steps in your case:

  1. Create a new instance with the same startup parameters as the original one.
  2. Wait until the new instance is running and then stop (not terminate) it.
  3. Detach the EBS boot volume from the new instance and delete this detached volume, as it is not required anymore.
  4. Create a new volume from the snapshot and attach it to the new instance.
  5. Restart the new instance which is now going to boot with the volume created from your snapshot.

This technique has been used by Colin Percival to enable running FreeBSD on EC2 via defenestration as well btw. (which includes some hints towards the virtualization issues):

EC2 Windows instances, on the other hand, are launched in HVM (Hardware Virtual Machine) mode — which FreeBSD supports very well. If we can somehow trick EC2 into launching FreeBSD the same way as it launches Windows, we can run FreeBSD on a wide range of instance types. How can we trick EC2? Take advantage of the fact that Elastic Block Store disks can be detached from EC2 instances and reattached to different instances, and replace the boot disk of a "Windows" instance with a disk containing FreeBSD.

share|improve this answer
    
Thanks - there's the quotes from Amazon reference that I found while formulating my answer. I'll give your answer the tick for its completeness :) –  Matt Connolly Feb 2 '12 at 0:40
    
@Matt: Thanks for making this effort more worthwhile even :) –  Steffen Opel Feb 2 '12 at 11:04
    
When attaching the new volume to the recreated VM (steps 4-5 of the solution above) I needed to use /dev/sda1 as the device parameter. –  JoshRivers Aug 30 '13 at 22:23

I have discovered that you can create an AMI only from the instance, not from existing snapshots. The commands to create an AMI from snapshots only support linux.

The command line command to create an AMI from a windows instance (running or stopped) is ec2-create-image. I've successfully done this using the ruby sdk. The command creates snapshots of the EBS volumes attached to the instance and then constructs the correct AMI using those snapshots. If you use the web console, it will shut the windows machine down. From command line / api you have a choice of not shutting it down, in which case you need to take the same care for data consistency as you would with making a snapshot anyway.

So if you have terminated your instance and don't have an AMI, you're up the creek. Alternatively you could start a new windows instance, and shut it down and then connect volumes made from your snapshots. I haven't tried this yet, but I would hope you can detach the boot volume and attach a new one.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.