Enable hibernation for an instance
To hibernate an instance, you must first enable it for hibernation while launching the instance.
Important
You can't enable or disable hibernation for an instance after you launch it.
- New console
-
To enable hibernation using the console
-
Follow the procedure to launch an instance, but don't launch the instance until you've completed the following steps to enable hibernation.
-
To enable hibernation, configure the following fields in the launch instance wizard:
-
Under Application and OS Images (Amazon Machine Image), select an AMI that supports hibernation. For more information, see Supported Windows AMIs.
-
Under Instance type, select a supported instance type. For more information, see Supported instance families.
-
Under Configure storage, choose Advanced (at the right), and specify the following information for the root volume:
-
For Size (GiB), enter the EBS root volume size. The volume must be large enough to store the RAM contents and accommodate your expected usage.
-
For Volume type, select a supported EBS volume type: General Purpose SSD (
gp2
andgp3
) or Provisioned IOPS SSD (io1
andio2
). -
For Encrypted, choose Yes. If you enabled encryption by default in this Amazon Region, Yes is selected.
-
For KMS key, select the encryption key for the volume. If you enabled encryption by default in this Amazon Region, the default encryption key is selected.
For more information about the prerequisites for the root volume, see Hibernation prerequisites.
-
-
Expand Advanced details, and for Stop - Hibernate behavior, choose Enable.
-
-
In the Summary panel, review your instance configuration, and then choose Launch instance. For more information, see Launch an instance using the new launch instance wizard.
-
- Old console
-
To enable hibernation using the console
-
Follow the Launch an instance using the old launch instance wizard procedure.
-
On the Choose an Amazon Machine Image (AMI) page, select an AMI that supports hibernation. For more information about supported AMIs, see Hibernation prerequisites.
-
On the Choose an Instance Type page, select a supported instance type, and choose Next: Configure Instance Details. For information about supported instance types, see Hibernation prerequisites.
-
On the Configure Instance Details page, for Stop - Hibernate Behavior, select the Enable hibernation as an additional stop behavior check box.
-
On the Add Storage page, for the root volume, specify the following information:
-
For Size (GiB), enter the EBS root volume size. The volume must be large enough to store the RAM contents and accommodate your expected usage.
-
For Volume Type, select a supported EBS volume type, General Purpose SSD (
gp2
andgp3
) or Provisioned IOPS SSD (io1
andio2
). -
For Encryption, select the encryption key for the volume. If you enabled encryption by default in this Amazon Region, the default encryption key is selected.
For more information about the prerequisites for the root volume, see Hibernation prerequisites.
-
-
Continue as prompted by the wizard. When you've finished reviewing your options on the Review Instance Launch page, choose Launch. For more information, see Launch an instance using the old launch instance wizard.
-
- Amazon CLI
-
To enable hibernation using the Amazon CLI
Use the run-instances command to launch an instance. Specify the EBS root volume parameters using the
--block-device-mappings file://mapping.json
parameter, and enable hibernation using the--hibernation-options Configured=true
parameter.aws ec2 run-instances \ --image-id
ami-0abcdef1234567890
\ --instance-typem5.large
\ --block-device-mappings file://mapping
.json \ --hibernation-options Configured=true \ --count1
\ --key-nameMyKeyPair
Specify the following in
mapping.json
.[ { "DeviceName": "
/dev/xvda
", "Ebs": { "VolumeSize":30
, "VolumeType": "gp2
", "Encrypted": true } } ]Note
The value for
DeviceName
must match the root device name that's associated with the AMI. To find the root device name, use the describe-images command.aws ec2 describe-images --image-id ami-
0abcdef1234567890
If you enabled encryption by default in this Amazon Region, you can omit
"Encrypted": true
. - PowerShell
-
To enable hibernation using the Amazon Tools for Windows PowerShell
Use the New-EC2Instance command to launch an instance. Specify the EBS root volume by first defining the block device mapping, and then adding it to the command using the
-BlockDeviceMappings
parameter. Enable hibernation using the-HibernationOptions_Configured $true
parameter.PS C:\>
$ebs_encrypt = New-Object Amazon.EC2.Model.BlockDeviceMapping
PS C:\>
$ebs_encrypt.DeviceName = "
/dev/xvda
"PS C:\>
$ebs_encrypt.Ebs = New-Object Amazon.EC2.Model.EbsBlockDevice
PS C:\>
$ebs_encrypt.Ebs.VolumeSize =
30
PS C:\>
$ebs_encrypt.Ebs.VolumeType = "
gp2
"PS C:\>
$ebs_encrypt.Ebs.Encrypted = $true
PS C:\>
New-EC2Instance ` -ImageId
ami-0abcdef1234567890
` -InstanceTypem5.large
` -BlockDeviceMappings $ebs_encrypt ` -HibernationOptions_Configured $true ` -MinCount1
` -MaxCount1
` -KeyNameMyKeyPair
Note
The value for
DeviceName
must match the root device name associated with the AMI. To find the root device name, use the Get-EC2Image command.Get-EC2Image -ImageId ami-
0abcdef1234567890
If you enabled encryption by default in this Amazon Region, you can omit
Encrypted = $true
from the block device mapping.
- Console
-
To view if an instance is enabled for hibernation
Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/
. -
In the navigation pane, choose Instances.
-
Select the instance and, on the Details tab, in the Instance details section, inspect Stop-hibernate behavior. Enabled indicates that the instance is enabled for hibernation.
- Amazon CLI
-
To view if an instance is enabled for hibernation
Use the describe-instances command and specify the
--filters "Name=hibernation-options.configured,Values=true"
parameter to filter instances that are enabled for hibernation.aws ec2 describe-instances \ --filters "Name=hibernation-options.configured,Values=true"
The following field in the output indicates that the instance is enabled for hibernation.
"HibernationOptions": { "Configured": true }
- PowerShell
-
To view if an instance is enabled for hibernation using the Amazon Tools for Windows PowerShell
Use the Get-EC2Instance command and specify the
-Filter @{ Name="hibernation-options.configured"; Value="true"}
parameter to filter instances that are enabled for hibernation.(Get-EC2Instance -Filter @{Name="hibernation-options.configured"; Value="true"}).Instances
The output lists the EC2 instances that are enabled for hibernation.