What steps do I need to take before changing the instance type of my EC2 Linux instance?

Last updated: 2020-06-22

My system requires more CPU or memory than is available on my current Amazon Elastic Compute Cloud (Amazon EC2) instance. What steps do I take before resizing my instance to be sure that the transition is successful? 

Short description

Changing the instance type of your EC2 Linux instance allows you to change the following:

  • Number of CPU cores
  • Amount of RAM
  • Amazon Elastic Block Store (Amazon EBS) optimization
  • Enhanced networking
  • GPU cores

Before changing instance types or instance families, verify if the current instance type and the new instance type are compatible.

Resolution

The following common issues cause compatibility problems when changing instance types. To be sure that your instance type change is successful, be sure that you review these areas. For a full list of compatibility issues, see Compatibility for resizing instances.

After you've verified compatibility, you can resize your Amazon EBS-backed instance.

Stop your instance

You must stop your instance before you change instance types. Before stopping your instance, be sure you understand the following:

  • If your instance is instance store-backed or has instance store volumes containing data, the data is lost when you stop the instance. If you are moving from one instance store-backed instance to another instance store-backed instance, you must migrate your instance store-backed instance. For more information, see Migrating an instance store-backed instance.
  • If your instance is part of an Amazon EC2 Auto Scaling group, stopping the instance may terminate the instance. If you launched the instance with Amazon EMR, AWS CloudFormation, or AWS Elastic Beanstalk, your instance might be part of an AWS Auto Scaling group. Instance termination in this scenario depends on the instance scale-in protection settings for your Auto Scaling group. If your instance is part of an Auto Scaling group, then temporarily remove the instance from the Auto Scaling group before starting the resolution steps.
  • If you're not using an Elastic IP address, stopping and starting the instance changes the public IP address of your instance. It's a best practice to use an Elastic IP address instead of a public IP address when routing external traffic to your instance. If you are using Route 53, you might have to update the Route 53 DNS records when the public IP changes.


Back up your data

It's a best practice to maintain backups of your instances and data. Consider creating an AMI or creating snapshots of your EBS volumes before you change your infrastructure.

Enhanced networking

If you're converting to an instance that supports enhanced networking, be sure that you install any required drivers and enable enhanced networking on your current instance. For more information, see Enhanced networking on Linux.

Nitro-based instance types

Before changing your instance to a Nitro-based instance type, check that the NVMe and ENA modules are installed on your instance and that any block devices listed in /etc/fstab are compatible with NVMe block device names (/dev/nvme1, /dev/nvme2, and so on). To automate these checks, run the NitroInstanceChecks script. For more information, see Why is my Linux instance not booting after I changed its type to a Nitro-based instance type and follow the instructions in the Run the NitroInstanceChecks script section.

After the script runs and you've made necessary updates, verify that the DRIVERS entry in /etc/udev/rules.d/70-persistent-net.rules is set to ? or ENA.

Use a text editor to access the file. The following example uses the vi editor.

vi /etc/udev/rules.d/70-persistent-net.rules

The correct entry appears as follows:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="01:23:45:67:89:ab", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0

Networking on current generation instances

Current generation instances launch only in a virtual private cloud (VPC). If your current instance is an EC2-Classic instance, then migrate the instance to a Linux instance in a VPC.


Did this article help you?

Anything we could improve?


Need more help?