I'm stuck in the storage stage. It says: To use hibernation, encrypt the root volume.. But I cannot click the encrypt checkbox, nor did I find any way to encrypt the root volume.
How can I create an ec2 instance which can be hibernated?
2.4k Views Asked by hansaplast AtThere are 2 best solutions below
On
A visual guide as of 2022
Prerequisites
First, check the AWS Hibernation prerequisites about the requirement of Hibernation, pay attention to OS, RAM Cap (less than 150GB), and the supported instance families.
To enable hibernation, space is allocated on the root volume to store the instance memory (RAM). Make sure that the root volume is large enough to store the RAM contents and accommodate your expected usage, e.g. OS, applications. To use hibernation, the root volume must be an encrypted EBS volume
EC2 Instance Creation Steps
Within the Launch an instance wizard (the wizard when you create the new EC2 instance), expand the Storage (volumes) and EBS Volumes section

Pay attention to the following attributes:
- Size (GiB): Make sure it's greater than the memory size and your expected usage
- Encrypted: Yes
- KMS Key: You can pick the default one for simplicity
Then scroll to the Advanced Details section, select Enable for the Stop - Hibernate behavior option

Then proceed to create your instance
Usage
To hibernate the created instance, select it from the dashboard, choose Instance state -> Hibernate instance

Update 2020-03
A lot has changed since my post below and Hibernation is now a piece of cake. Encryption can be done in the normal ec2 creation flow in AWS console, Amazon Linux 2 is also supported.
All you need to be aware of:
Original post:
In the end I was stuck at many stages, the official documentation is somehow lacking so I thought I'd document my findings:
In order to hibernate an instance it needs to be of type C3, C4, C5, M3, M4, M5, R3, R4 or R5. Plus it needs to be a Amazon Linux 1 AMI (this may be outdated, see here for an up to date list). I started with a Linux 2 AMI and didn't get any warning until it just didn't work in the end (only showing
Suspend key pressed.,Requested operation not supported, ignoring.in /var/log/messages), even their suggested steps to enable hibernation didn't work, asec2-hibinit-agentis not an available packet on Amazon Linux 2.Hibernation requires the boot volume to be encrypted. In order to achieve that, you need to encrypt the AWS Linux 1 AMI prior to starting the launch wizard:
ami-0cfbf4f6db41068aceu-central-1, theamiand thekmskey with your ownWait a few minutes until you see the new AMI showing up in EC2 -> AMIs
AMIs(in EC2 AWS console) launch your new AMIEnable hibernation as an additional stop behaviorTo test it:
tail -f /var/log/messageson the ec2 instance to check for errorsaws ec2 stop-instances --instance-ids "i-…" --hibernateto hibernate via terminal, or alternatively over aws consoleAdditionally I saw this error in
/var/log/messages:Agent hibernate - AccessDeniedException: User: arn:… is not authorized to perform: ssm:UpdateInstanceInformation on resource: ssm:UpdateInstanceInformation. I needed to attachAmazonEC2RoleforSSMandAmazonSSMAutomationRoleto make these errors go away.