Step-by-Step Guide to Migrating AWS EC2 from t2 to t3
Overview
With the arrival of the t3 instance family on AWS EC2, I expected the migration to be a breeze, but I ran into a few snags. This post summarizes where I got stuck.
The instance I worked with this time was an HVM instance running ubuntu 16.04.5 LTS.
What makes t3 better than t2?
- Cheaper! *1
- With t2.small and below, the number of virtual cores was 1, but with t3 it's doubled!
- For the same instance size, t3 grants twice the credits of t2!
- Unlimited credit mode is enabled by default!
- EBS optimization is enabled by default
The general flow of migrating from t2 to t3
In short, you need to install the ena module and enable EC2 ENA support.
- Stop the t2 instance
- Create an AMI
- Start the t2 instance
- Install the kernel module (ena) on the t2 instance
- Verify the ena module installation
- Stop the t2 instance
- Change the instance type to t3 (if you also want credit: unlimited, do it here)
- Start the t3 instance
What is ENA?
Elastic Network Adapter – A High-Performance Network Interface for Amazon EC2
It is built to lighten the processor's workload and to create a short, efficient path between the vCPUs that generate or process network packets.
The page Enabling Enhanced Networking with the Elastic Network Adapter (ENA) on Linux Instances states the following.
Amazon EC2 provides enhanced networking capabilities to C5, C5d, F1, G3, H1, I3, m4.16xlarge, M5, M5d, P2, P3, R4, R5, R5d, X1, X1e, and z1d instances via the Elastic Network Adapter (ENA).
Enhanced networking cannot be managed from the Amazon EC2 console.
Supported only on HVM instances
To summarize,
- A high-performance network interface for Amazon EC2
- Supported in HVM (Hardware-assisted VM: full virtualization) environments.
- Not supported in PV (ParaVirtual: paravirtualization) environments.
- By going through the kernel module called ENA, the instance can use enhanced networking capabilities.
You can check pv/hvm under the "Virtualization" item in the EC2 description in the AWS console.
If it's pv, you'll need to consider migrating to hvm.
Let's proceed with the configuration below.
Procedure for Enabling ENA
The following assumptions apply.
- A backup, such as taking an AMI, has been completed.
- Migrating from t2.small to t3.small.
Enabling enhanced networking on Ubuntu
ubuntu:~$ sudo apt-get update && sudo apt-get upgrade -y linux-aws
How to handle other OSes is also described in the earlier Enabling Enhanced Networking with the Elastic Network Adapter (ENA) on Linux Instances.
If the error W: mdadm: /etc/mdadm/mdadm.conf defines no arrays. occurs
Add the following line to the `/etc/mdadm/mdadm.conf` file.
ARRAY <ignore> devices=<ルートデバイス>
In my case, I appended the following line at the very bottom, and when I ran the command again it went through.
ARRAY <ignore> devices=/dev/sda1
Displaying information about the ena kernel module
Run `modinfo ena`, and if it displays output like the following, you're good.
ubuntu:~$ modinfo ena filename: /lib/modules/4.4.0-81-generic/kernel/drivers/net/ethernet/amazon/ena/ena.ko version: 1.1.2 license: GPL description: Elastic Network Adapter (ENA) author: Amazon.com, Inc. or its affiliates ...
Enabling EC2 ENA support
// Stop the instance macOS%$ aws ec2 stop-instances --instance-ids <instance id> // Configure ENA support macOS%$ aws ec2 modify-instance-attribute --instance-id <instance id> --ena-support true // EBS optimization (optional) macOS%$ aws ec2 modify-instance-attribute --instance-id <instance id> --ebs-optimized // credit unlimited setting (optional) macOS%$ aws ec2 modify-instance-credit-specification --instance-credit-specification "InstanceId=i-<instance id>,CpuCredits=unlimited" // Change the instance type macOS%$ aws ec2 modify-instance-attribute --instance-id <instance id> --instance-type t3.small // Start the instance macOS%$ aws ec2 start-instances --instance-ids <instance id>
And with that, I was able to make my t3 debut ♪

