Read on:

AWS for Beginners: What is AWS VPC Peering and Why Transit Gateway is Required? Part 24

AWS EC2 Hibernate is a feature of Amazon Web Services (AWS) Elastic Compute Cloud (EC2) that allows users to “hibernate” their EC2 instances instead of stopping or terminating them. When an EC2 instance is hibernated, the current state of the instance’s memory and all the contents of the instance’s disks are written to an encrypted storage location in Amazon S3. When the user resumes the instance, the instance is restored to its previous state, including its RAM contents, which allows the user to resume from where they left off, without the need to restart any applications or reload data.

Protect Your Data with BDRSuite

Cost-Effective Backup Solution for VMs, Servers, Endpoints, Cloud VMs & SaaS applications. Supports On-Premise, Remote, Hybrid and Cloud Backup, including Disaster Recovery, Ransomware Defense & more!

Note that not all EC2 instances support hibernation, and there may be additional costs associated with using this feature, such as S3 storage costs. Additionally, hibernation may take longer to start and stop an instance than other options, such as stopping an instance.

1. Login to AWS console and navigate to the EC2 instance page.

AWS EC2 hibernate

2. Kindly note that not all the EC2 instances support hibernate feature. To identify hibernate supported EC2 instances, use the AWS CLI and run the following command.

Download Banner
[cloudshell-user@ip-10-4-23-177 ~]$ aws ec2 describe-instance-types –filters Name=hibernation-supported,Values=true –query “InstanceTypes[*].[InstanceType]” —
output text | sort
c4.2xlarge
c4.4xlarge
c4.8xlarge
c4.large
c4.xlarge
c5.12xlarge
c5.18xlarge
c5.2xlarge
c5.4xlarge
c5.9xlarge
and so on..

3. Hibernate feature can’t be enabled once the instance is launched. You need to enable this feature while launching the instance.

AWS EC2 hibernate

4. You can find the “hibernate behavior” option in the advanced EC2 options section.

AWS EC2 hibernate

5. You must enable “disk encryption” to use the “hibernate” feature. This ensures that In-memory content is protected securely.

AWS EC2 hibernate

6. Here we can see that instance is launched successfully.

AWS EC2 hibernate

7. Before “Hibernate” instance, let’s run some job to append numbers automatically for every 10 seconds. This job will resume once you bring instance back to running from hibernate state.

Login to EC2 instance.

uxpro-$ ssh -i mac-m1-ohio.pem ec2-user@3.19.72.220
The authenticity of host ‘3.19.72.220 (3.19.72.220)’ can’t be established.
ED25519 key fingerprint is SHA256:uq0VyWL7TjGncbCbvxulJLjSaGBSuhFHtSQ3QDUS5KQ.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added ‘3.19.72.220’ (ED25519) to the list of known hosts.

__| __|_ )
_| ( / Amazon Linux 2 AMI
___|\___|___|

https://aws.amazon.com/amazon-linux-2/
[ec2-user@ip-172-31-32-136 ~]$

8. Create a script called “counter.sh” like below and make it executable.

[ec2-user@ip-172-31-32-136 ~]$ cat counter.sh
#!/bin/bash

total=”${1}”

for ((i = 0; i < total; ++i)); do echo "${i}" sleep 10 done [ec2-user@ip-172-31-32-136 ~]$ chmod +x counter.sh [ec2-user@ip-172-31-32-136 ~]$

9. Execute the script in the background and add nohup. This job will be keep on appending numbers sequentially up to 1000.

ec2-user@ip-172-31-32-136 ~]$ nohup ./counter.sh 1000 &
[1] 2608
[ec2-user@ip-172-31-32-136 ~]$ nohup: ignoring input and appending output to ‘nohup.out’

[ec2-user@ip-172-31-32-136 ~]$ cat nohup.out
0
[ec2-user@ip-172-31-32-136 ~]$ cat nohup.out
0
1
[ec2-user@ip-172-31-32-136 ~]$

10. To hibernate the instance, click on “Instance state” and click on “Hibernate instance”

AWS EC2 hibernate

11. Once the instance hibernated successfully, we can see that instance will be in “stopped state”

AWS EC2 hibernate

12. Start the instance from the portal.

13. Login to the EC2 instance. Instance might come up with new IP address.

uxpro-$ ssh -i mac-m1-ohio.pem ec2-user@18.223.112.214
The authenticity of host ‘18.223.112.214 (18.223.112.214)’ can’t be established.
ED25519 key fingerprint is SHA256:uq0VyWL7TjGncbCbvxulJLjSaGBSuhFHtSQ3QDUS5KQ.
This host key is known by the following other names/addresses:
~/.ssh/known_hosts:27: 3.19.72.220
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added ‘18.223.112.214’ (ED25519) to the list of known hosts.
Last login: Sat Feb 18 16:15:02 2023 from 49.207.202.238

__| __|_ )
_| ( / Amazon Linux 2 AMI
___|\___|___|

https://aws.amazon.com/amazon-linux-2/
[ec2-user@ip-172-31-32-136 ~]$ cat nohup.out
0
1
2
3
4
5
6
7
8
9
10

Here we can see that the script has started running and appending numbers in nohup.out file.

Conclusion:

The hibernation feature is particularly useful for instances that have long initialization times or instances that require a lot of configuration and customization. By using hibernation, the user can avoid the overhead of starting up the instance and configuring it every time they need to use it.

Embark on a Thrilling Journey: Explore Free AWS EC2 Instance Backup!

Discover the power of secure and seamless AWS EC2 instance backup with BDRSuite, and get access to backup up to 10 EC2 instances for free. Unleash the full potential of your cloud infrastructure and safeguard your valuable data with confidence. Don’t miss this adventure—claim your free trial today!

Ready to start? Download BDRSuite now and take the first step towards protecting your data in the cloud. Want to learn more about AWS backup using BDRSuite

Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.

Rate this post