Resizing a Amazon AWS EC2 EBS-backed Instance
This blog talks about changing the instance type (or machine size) of your EBS-backed Instance, using the AWS management console. It is a very simple process –
- Stop your running instance
- Once stopped, you get an option to ‘Change instance type’. Select a new instance type.
- Start the instance.
Simple, as it looks, there are a few things we need to know and consider before we resize.
What is EBS?
Amazon Elastic Block Store (EBS) provides durable, block-level storage volumes that you can attach to a running Amazon EC2 instance. The volume persists independently from the running life of an Amazon EC2 instance. It is used if data requires long term persistence, especially primary storage for databases or file systems.
The other storage that AWS has is an Instance Store (Ephemeral Storage). Many Amazon EC2 instances can access storage from disks that are physically attached to the host computer. This disk storage is referred to as instance store. Instance store provides temporary block-level storage for Amazon EC2 instances. The data on an instance store volume persists only during the life of the associated Amazon EC2 instance; if you stop or terminate an instance, any data on instance store volumes is lost.
What is EBS-backed Instance?
All AMIs (Amazon Machine Image) are categorized as either backed by Amazon EBS or backed by instance store. The former means that the root device for an instance launched from the AMI is an Amazon EBS volume. The latter means that the root device for an instance launched from the AMI is an instance store volume.
To check the type on AWS management console –
Go to the EC2 Dashboard, Go to ‘Instances’ page, Check the value of Root Device Type in the Description tab:
If the value is ebs, this is an Amazon EBS-backed AMI.
If the value is instance store, this is an instance store-backed AMI.
Stopped State –
You can stop an Amazon EBS-backed instance, but not an Amazon EC2 instance store-backed instance. Stopping causes the instance to stop running (its status goes from running to stopping to stopped). A stopped instance persists in Amazon EBS, which allows it to be restarted. Stopping is different from terminating; you can’t restart a terminated instance.
Because Amazon EC2 instance store-backed AMIs can’t be stopped, they’re either running or terminated.
Choosing the new Instance type
New instance type must be compatible with the current instance AMI. They should have the same architecture (Cannot change from 32 bit to 64 bit or vice versa). Also, an instance can only be resized to an instance type that supports its method of virtualization. Amazon Machine Images (AMIs) use one of two types of virtualization: paravirtual (PV) or hardware virtual machine (HVM) and AMIs can only be launched on instance types that support their method of virtualization. So, it is important to thoroughly check the compatibility of the instance types.
The Steps for changing the Instance type for EBS-backed Instance:
1. Stopping the instance:
As we have learnt that the data stored on the ephemeral storage or instance store is lost when the instance is stopped, it is important that we back up the required data from ephemeral storage to the EBS volumes.
Also, please note that, for EC2-Classic instances, public and private IP addresses are released when the instance is stopped, new addresses are assigned when restarted and the Elastic IP addresses are disassociated. For EC2-VPC, the private IP is retained but public is released and Elastic IP addresses are also retained. So, if your instance is EC2-Classic, make a note of the Elastic IP addresses if any.
(Note – EC2-Classic and EC2-VPC are the two platforms supported by Amazon EC2. In EC2-Classic, the instances run in a single, flat network that you share with other customers. In EC2-VPC, the instances run in a virtual private cloud (VPC) that’s logically isolated to a particular AWS account.)
To Stop, in the navigation pane, click ‘Instances’, select the instance, click ‘Actions’ and click ‘Stop’. In confirmation dialog, click “Yes, Stop”.
It may take a few minutes to stop. Check that the instance state is changed to “stopped”.
2. Change the instance type:
Select the stopped instance, and click ‘Actions’. Then click on ‘Change instance type’ (this option is enabled only when the instance is in ‘stopped’ state).
In the change instance type dialog, in the Instance Type list, select the type that you have chosen and click ‘Apply’.
3. Restart the Instance:
Select the stopped instance, and click ‘Actions’ and then click ‘Start’. In the confirmation dialog, click ‘Yes, Start’.
It may take a few minutes for the instance to start. Check that the instance state is changed to ‘running’.
For EC2- Classic instances, the new Public and Private DNS and Private IPs would appear on the description tab. If your instance had any associated Elastic IP addresses, be sure to re-associate them.
Helical IT Solutions