7

I've got an application I'd like to move to EC2. It will likely spend more than half the day completely dormant, so I'm trying to come up with a good solution for starting and stopping it as needed. It takes a few minutes to start up from nothing, so it would be nice if i could hibernate the OS for quicker resumes. I've seen a couple forum discussions on the topic of hibernation within EC2, but never anything conclusive. Has anyone found a working solution to this, or at least some resources that could help me out?

Jeff Ferland
  • 20,239
  • 2
  • 61
  • 85
Dan
  • 351
  • 1
  • 7
  • 18

4 Answers4

11

This has been discussed on the EC2 forums.

Highlights, direct from Amazon's mouth:

  1. if you do manage to hibernate the OS your Instance will still be in a running state i.e. you will be paying for the instance.

  2. how do you plan to wake up this instance from it's sleeping state.

This really does not sound like it will work, We would recommend that you configure your instance to automatically launch all the services you need at boot time and use the stop/start feature of EBS backed instances as a solution to your problem.

(or, in plain English -- Don't bother. It won't save you any money, and it probably won't work anyway)

voretaq7
  • 79,345
  • 17
  • 128
  • 213
3

I just hibernated an EBS based Windows AMI and then restarted it and it resumed fine. I would guess Linux works the same (as long as it stores the hibernate data to an EBS volume and then powers off the virtual machine).

(hibernation was disabled in the AMI, I turned it on using

powercfg /H on

and then performing the hibernation with

shutdown /h

)

PS: Take note of this: when an instance is stopped and later started again, all the instance stores are reset! Operating systems don't like disk content changing between hibernate and resume. (after resuming the OS may still show some remains of the previous disk content that is cached in the OS file cache)

David Balažic
  • 419
  • 6
  • 19
  • 1
    Yes, but did you pay for the time it was hibernating? – Michael Hampton Aug 07 '13 at 00:23
  • And prior to the other answer, this is still not a supported solution. – Frederik Aug 07 '13 at 00:58
  • The instance is stopped. they don't charge for stopped state. Quoting from http://aws.amazon.com/ec2/#pricing "Pricing is per instance-hour consumed for each instance, from the time an instance is launched until it is terminated or stopped." Or from http://aws.amazon.com/ec2/faqs/#What_defines_billable_EC2_instance_hours Q: What defines billable EC2 instance-hours? Instance-hours are billed for any time your instances are in a “running” state. If you no longer wish to be charged for your instance, you must "stop" or "terminate" the instance to avoid being billed for additional instance-hours. – David Balažic Aug 07 '13 at 01:05
  • As for billing, I did not run long enough to be able to tell. – David Balažic Aug 07 '13 at 01:29
  • Interesting. When I tried hibernating a Linux instance, it didn't work. That was over a year ago though, so it's entirely likely that things have caged since then. I'll do some more experimentation. – Dan Aug 07 '13 at 10:26
  • They can't really prevent hibernation, since hibernation is basically: write some data to disk, then power off. Which is the same as a regular shutdown (except less data is typically written at shutdown), which is allowed. – David Balažic Nov 12 '14 at 18:21
  • What version of Windows was this on? In [this thread](https://forums.aws.amazon.com/thread.jspa?messageID=483735#483735) support staff indicate hibernation may work on Win Server 2003 because `.. old version of Windows (that had to deal with pre-ACPI, older BIOSes), like Windows 2003 server, don't rely on cooperation from the BIOS (or hypervisor) to wakeup up from S4 state.` – Molomby Jan 20 '16 at 23:32
  • I'm 99% it was not 2003. Probably 2008 or 2012. Sorry, don't remember any more. – David Balažic Jan 21 '16 at 14:49
3

Stumbled upon this question, EC2 Hibernation is now supported for Ubuntu 18.04.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Hibernate.html#hibernating-prerequisites

Yuvraj Gupta
  • 131
  • 2
2

Old question, but it seems this feature has been implemented, at least for Amazon Linux 1, with an encrypted root volume. Hopefully Ubuntu support is on its way.

https://aws.amazon.com/blogs/aws/new-hibernate-your-ec2-instances/

user2561747
  • 121
  • 2