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

My system requires more CPU or memory than is available on my current Amazon Elastic Compute Cloud (Amazon EC2) Linux instance. I want to know what steps I need to take before I change my instance type.

Short descriptionTo optimize your Amazon EC2 Linux instance for your workload, change the instance type. Changing the instance type lets you modify the following configurations for your workload:Number of CPU coresAmount of RAMAmount of assigned instance store spaceAmazon Elastic Block Store (Amazon EBS) optimizationEnhanced networkingGPU coresFPGAsMachine learning acceleratorsNote: It's a best practice to maintain backups of your instances and data. Before you change your infrastructure, create an AMI or create snapshots of your EBS volumes.

ResolutionVerify that your current instance type is compatible with the new instance typeBefore you change instance types or instance families, verify that the current instance type and the new instance type are compatible. For a list of compatibility issues, see Compatibility for changing the instance type.After you verify compatibility, you can change the instance type of your Amazon EBS-backed instance.Stop your instanceBefore you change instance types, you must stop your instance.Important:If your instance is instance store backed or has instance store volumes that contain data, then the data is lost when you stop the instance. If you're moving from one instance store-backed instance to another instance store-backed instance, then you must migrate the instance. For more information, see Change the instance type of an instance store-backed instance.If your instance is part of an Amazon EC2 Auto Scaling group, then stopping the instance might terminate the instance. If you launched the instance with Amazon EMR, AWS CloudFormation, or AWS Elastic Beanstalk, then 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, then 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're using Amazon Route 53, then you might have to update the Route 53 DNS records when the public IP changes.Enhanced networkingIf you're converting to an instance that supports enhanced networking, then install any required drivers, and turn on enhanced networking on your current instance. For more information, see Enhanced networking on Linux.Nitro-based instance typesIf you're changing your instance to a Nitro-based instance type, then take the following actions:Confirm that you installed the NVMe and ENA modules on your instance.Check that any block devices that are listed in /etc/fstab are compatible with NVMe block device names (/dev/nvme1, /dev/nvme2, and so on).Amazon EBS volumes are exposed as NVMe devices to these instance types, and the device names are changed on a stop or start event. To avoid volume mismatch, use the UUIDs or labels file system to mount the file systems.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? Follow the instructions in the Run the NitroInstanceChecks script section.After the script runs and you make 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.rulesThe correct entry appears as follows:SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="01:23:45:67:89:ab", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0Networking on current generation instancesCurrent 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.Mixing EC2 architecturesIf your instance's source AMI is built for a specific architecture, then you're restricted to creating instance types of the same architecture. Examples of AMIs that are built for specific architecture include 32-bit (i386), 64-bit (x86_64), or 64-bit ARM (arm64). This is also the case if your instance is running an AMI that's created for the mac1 instance type. You can't move these images between instance types.

Related informationStatus checks for your instancesAmazon EC2 pricingWhat do I need to do before migrating my EC2 instance to a sixth generation instance to make sure that I get maximum network performance?